-
Notifications
You must be signed in to change notification settings - Fork 571
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix_coverage
- Loading branch information
Showing
48 changed files
with
381 additions
and
185 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
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 |
---|---|---|
|
@@ -15,5 +15,5 @@ | |
} | ||
}, | ||
"npmClient": "npm", | ||
"version": "1.4.2" | ||
"version": "1.4.3" | ||
} |
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
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
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
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
3 changes: 3 additions & 0 deletions
3
packages/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/README.md
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 @@ | ||
# demo-{{name}} | ||
|
||
this is a demo for midway. |
12 changes: 12 additions & 0 deletions
12
packages/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/_.gitignore
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,12 @@ | ||
logs/ | ||
npm-debug.log | ||
yarn-error.log | ||
node_modules/ | ||
package-lock.json | ||
yarn.lock | ||
coverage/ | ||
.idea/ | ||
run/ | ||
.DS_Store | ||
*.sw* | ||
*.un~ |
23 changes: 23 additions & 0 deletions
23
packages/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/_package.json
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,23 @@ | ||
{ | ||
"name": "demo-{{name}}", | ||
"version": "1.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"midway": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"midway-bin": "1", | ||
"midway-demo-lib": "1" | ||
}, | ||
"engines": { | ||
"node": ">=8.9.0" | ||
}, | ||
"scripts": { | ||
"dev": "NODE_ENV=local midway-bin dev --ts", | ||
"debug": "NODE_ENV=local midway-bin debug --ts", | ||
"test": "midway-bin test --ts", | ||
"cov": "midway-bin cov --ts", | ||
"ci": "midway-bin cov --ts", | ||
"build": "midway-bin build -c" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...es/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/src/app/controller/home.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,11 @@ | ||
import { controller, get, provide } from 'midway'; | ||
|
||
@provide() | ||
@controller('/') | ||
export class HomeController { | ||
|
||
@get('/') | ||
async index(ctx) { | ||
ctx.body = `Welcome to midwayjs!`; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...es/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/src/app/controller/user.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,16 @@ | ||
import { controller, get, inject, provide } from 'midway'; | ||
import { IUserService, IUserResult } from '../../interface'; | ||
|
||
@provide() | ||
@controller('/user') | ||
export class UserController { | ||
@inject('userService') | ||
service: IUserService; | ||
|
||
@get('/:id') | ||
async getUser(ctx): Promise<void> { | ||
const id: number = ctx.params.id; | ||
const user: IUserResult = await this.service.getUser({id}); | ||
ctx.body = {success: true, message: 'OK', data: user}; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...y-init/boilerplate/midway-demo-boilerplate/boilerplate/src/app/public/README.md
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 @@ | ||
## public static file directory! |
12 changes: 12 additions & 0 deletions
12
.../midway-init/boilerplate/midway-demo-boilerplate/boilerplate/src/config/config.default.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,12 @@ | ||
export = (appInfo: any) => { | ||
const config: any = exports = {}; | ||
|
||
// use for cookie sign key, should change to your own and keep security | ||
config.keys = appInfo.name + '_{{keys}}'; | ||
|
||
// add your config here | ||
config.middleware = [ | ||
]; | ||
|
||
return config; | ||
}; |
4 changes: 4 additions & 0 deletions
4
packages/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/src/config/plugin.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,4 @@ | ||
// had enabled by midway | ||
// export = { | ||
// static: true, | ||
// }; |
23 changes: 23 additions & 0 deletions
23
packages/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/src/interface.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,23 @@ | ||
/** | ||
* @description User-Service parameters | ||
*/ | ||
export interface IUserOptions { | ||
id: number; | ||
} | ||
|
||
/** | ||
* @description User-Service response | ||
*/ | ||
export interface IUserResult { | ||
id: number; | ||
username: string; | ||
phone: string; | ||
email?: string; | ||
} | ||
|
||
/** | ||
* @description User-Service abstractions | ||
*/ | ||
export interface IUserService { | ||
getUser(options: IUserOptions): Promise<IUserResult>; | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/src/service/user.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,15 @@ | ||
import { provide } from 'midway'; | ||
import { IUserService, IUserOptions, IUserResult } from '../interface'; | ||
|
||
@provide('userService') | ||
export class UserService implements IUserService { | ||
|
||
async getUser(options: IUserOptions): Promise<IUserResult> { | ||
return { | ||
id: options.id, | ||
username: 'mockedName', | ||
phone: '12345678901', | ||
email: 'xxx.xxx@xxx.com', | ||
}; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...way-init/boilerplate/midway-demo-boilerplate/boilerplate/test/app/controller/home.test.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,11 @@ | ||
const { app, assert } = require('midway-mock/bootstrap'); | ||
|
||
describe('test/app/controller/home.test.ts', () => { | ||
|
||
it('should GET /', () => { | ||
return app.httpRequest() | ||
.get('/') | ||
.expect('Welcome to midwayjs!') | ||
.expect(200); | ||
}); | ||
}); |
Oops, something went wrong.