-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: windows relative * chore: relative path * fix: relative * test: add issue 11 case * fix: lint * test: add esm case
- Loading branch information
1 parent
9b54b14
commit 1c8b5eb
Showing
21 changed files
with
300 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { MidwayConfig } from '@midwayjs/core'; | ||
|
||
const config: MidwayConfig = {}; | ||
|
||
config.koa = { | ||
port: 7001, | ||
} | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Configuration, App, Inject } from '@midwayjs/decorator'; | ||
import * as koa from '@midwayjs/koa'; | ||
import * as bodyParser from 'koa-bodyparser'; | ||
import * as session from 'koa-session'; | ||
import * as axios from '@midwayjs/axios'; | ||
|
||
@Configuration({ | ||
imports: [ | ||
koa, | ||
axios, | ||
], | ||
}) | ||
export class ContainerLifeCycle { | ||
@App() | ||
app: koa.Application; | ||
|
||
@Inject() | ||
httpService: axios.HttpService; | ||
|
||
async onReady() { | ||
this.app.keys = ['default value']; | ||
this.app.use(session({key: "SESSIONID"}, this.app)) | ||
// bodyparser options see https://github.com/koajs/bodyparser | ||
this.app.useMiddleware([bodyParser()]); | ||
|
||
return await this.httpService.get('http://www.weather.com.cn/data/cityinfo/101010100.html'); | ||
} | ||
} |
Empty file.
13 changes: 13 additions & 0 deletions
13
test/fixtures/base-app-esm/src/controller/test/api.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Inject, Controller, Get } from '@midwayjs/decorator'; | ||
import { Context } from '@midwayjs/koa'; | ||
|
||
@Controller('/api') | ||
export class APIController { | ||
@Inject() | ||
ctx: Context; | ||
|
||
@Get('/get_user') | ||
async getUser() { | ||
return 'bbb'; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
test/fixtures/base-app-esm/src/controller/ych/home.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Controller, Get } from '@midwayjs/decorator'; | ||
|
||
@Controller('/') | ||
export class HomeController { | ||
@Get('/') | ||
async home(): Promise<string> { | ||
return 'home value'; | ||
} | ||
|
||
@Get('/login') | ||
async login(): Promise<string> { | ||
return 'login page' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @description User-Service parameters | ||
*/ | ||
export interface IUserOptions { | ||
uid: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Provide } from '@midwayjs/decorator'; | ||
import { IUserOptions } from '../interface'; | ||
|
||
@Provide() | ||
export class UserService { | ||
async getUser(options: IUserOptions) { | ||
return { | ||
uid: options.uid, | ||
username: 'mockedName', | ||
phone: '12345678901', | ||
email: '[email protected]', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"compileOnSave": true, | ||
"compilerOptions": { | ||
"target": "es2018", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"inlineSourceMap":true, | ||
"noImplicitThis": true, | ||
"noUnusedLocals": true, | ||
"stripInternal": true, | ||
"skipLibCheck": false, | ||
"pretty": true, | ||
"declaration": true, | ||
"typeRoots": [ "./typings", "./node_modules/@types"], | ||
"outDir": "dist" | ||
}, | ||
"exclude": [ | ||
"dist", | ||
"node_modules", | ||
"test" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { MidwayConfig } from '@midwayjs/core'; | ||
|
||
const config: MidwayConfig = {}; | ||
|
||
config.koa = { | ||
port: 7001, | ||
} | ||
|
||
export default config; |
Empty file.
13 changes: 13 additions & 0 deletions
13
test/fixtures/issue11/src/controller/test/api.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Inject, Controller, Get } from '@midwayjs/decorator'; | ||
import { Context } from '@midwayjs/koa'; | ||
|
||
@Controller('/api') | ||
export class APIController { | ||
@Inject() | ||
ctx: Context; | ||
|
||
@Get('/get_user') | ||
async getUser() { | ||
return 'bbb'; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
test/fixtures/issue11/src/controller/ych/home.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Controller, Get } from '@midwayjs/decorator'; | ||
|
||
@Controller('/') | ||
export class HomeController { | ||
@Get('/') | ||
async home(): Promise<string> { | ||
return 'home value'; | ||
} | ||
|
||
@Get('/login') | ||
async login(): Promise<string> { | ||
return 'login page' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Configuration, App, Inject } from '@midwayjs/decorator'; | ||
import * as koa from '@midwayjs/koa'; | ||
import * as bodyParser from 'koa-bodyparser'; | ||
import { join } from 'path'; | ||
import * as session from 'koa-session'; | ||
import * as axios from '@midwayjs/axios'; | ||
|
||
@Configuration({ | ||
imports: [ | ||
koa, | ||
axios, | ||
], | ||
importConfigs: [join(__dirname, './config')], | ||
}) | ||
export class ContainerLifeCycle { | ||
@App() | ||
app: koa.Application; | ||
|
||
@Inject() | ||
httpService: axios.HttpService; | ||
|
||
async onReady() { | ||
this.app.keys = ['default value']; | ||
this.app.use(session({key: "SESSIONID"}, this.app)) | ||
// bodyparser options see https://github.com/koajs/bodyparser | ||
this.app.useMiddleware([bodyParser()]); | ||
|
||
return await this.httpService.get('http://www.weather.com.cn/data/cityinfo/101010100.html'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @description User-Service parameters | ||
*/ | ||
export interface IUserOptions { | ||
uid: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Provide } from '@midwayjs/decorator'; | ||
import { IUserOptions } from '../interface'; | ||
|
||
@Provide() | ||
export class UserService { | ||
async getUser(options: IUserOptions) { | ||
return { | ||
uid: options.uid, | ||
username: 'mockedName', | ||
phone: '12345678901', | ||
email: '[email protected]', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"compileOnSave": true, | ||
"compilerOptions": { | ||
"target": "es2018", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"inlineSourceMap":true, | ||
"noImplicitThis": true, | ||
"noUnusedLocals": true, | ||
"stripInternal": true, | ||
"skipLibCheck": false, | ||
"pretty": true, | ||
"declaration": true, | ||
"typeRoots": [ "./typings", "./node_modules/@types"], | ||
"outDir": "dist" | ||
}, | ||
"exclude": [ | ||
"dist", | ||
"node_modules", | ||
"test" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters