-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7ef312
commit 1680d29
Showing
15 changed files
with
62 additions
and
178 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
17 changes: 0 additions & 17 deletions
17
packages/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/.editorconfig
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
packages/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/.vscode/launch.json
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
packages/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/.vscode/settings.json
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
packages/midway-init/boilerplate/midway-demo-boilerplate/boilerplate/.vscode/tasks.json
This file was deleted.
Oops, something went wrong.
8 changes: 7 additions & 1 deletion
8
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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# demo-{{name}} | ||
|
||
this is a demo for midway. | ||
this is a simple template for midway examples. | ||
you can push it to midway-examples after created or find bugs. | ||
this template not include tslint and @types package.this can be find in package called midway-demo-lib. | ||
|
||
这是一个最精简的用于提交到 midway-examples 的代码模板。 | ||
通常用于复现代码 bug 或者创建一个 demo 提交到 midway-exmaples。 | ||
这个模板不包括 tslint,以及常见的 @types 等,这些都被包括在一个叫 midway-demo-lib 的包中。 |
9 changes: 6 additions & 3 deletions
9
...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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { controller, get, provide } from 'midway'; | ||
import { Context, controller, inject, get, provide } from 'midway'; | ||
|
||
@provide() | ||
@controller('/') | ||
export class HomeController { | ||
|
||
@inject() | ||
ctx: Context; | ||
|
||
@get('/') | ||
async index(ctx) { | ||
ctx.body = `Welcome to midwayjs!`; | ||
async index() { | ||
this.ctx.body = `Welcome to midwayjs!`; | ||
} | ||
} |
12 changes: 8 additions & 4 deletions
12
...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 |
---|---|---|
@@ -1,16 +1,20 @@ | ||
import { controller, get, inject, provide } from 'midway'; | ||
import { Context, controller, get, inject, provide } from 'midway'; | ||
import { IUserService, IUserResult } from '../../interface'; | ||
|
||
@provide() | ||
@controller('/user') | ||
export class UserController { | ||
|
||
@inject() | ||
ctx: Context; | ||
|
||
@inject('userService') | ||
service: IUserService; | ||
|
||
@get('/:id') | ||
async getUser(ctx): Promise<void> { | ||
const id: number = ctx.params.id; | ||
async getUser(): Promise<void> { | ||
const id: number = this.ctx.params.id; | ||
const user: IUserResult = await this.service.getUser({id}); | ||
ctx.body = {success: true, message: 'OK', data: user}; | ||
this.ctx.body = {success: true, message: 'OK', data: user}; | ||
} | ||
} |
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
10 changes: 7 additions & 3 deletions
10
...rplate/midway-ts-ant-design-pro-boilerplate/boilerplate/server/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 |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { Context, controller, get, provide } from 'midway'; | ||
import { Context, inject, controller, get, provide } from 'midway'; | ||
|
||
@provide() | ||
@controller('/') | ||
export class HomeController { | ||
|
||
@inject() | ||
ctx: Context; | ||
|
||
@get('/') | ||
async index(ctx: Context) { | ||
await ctx.render('index'); | ||
async index() { | ||
await this.ctx.render('index'); | ||
} | ||
} |
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
9 changes: 6 additions & 3 deletions
9
...ages/midway-init/boilerplate/midway-ts-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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { Context, controller, get, provide } from 'midway'; | ||
import { Context, inject, controller, get, provide } from 'midway'; | ||
|
||
@provide() | ||
@controller('/') | ||
export class HomeController { | ||
|
||
@inject() | ||
ctx: Context; | ||
|
||
@get('/') | ||
async index(ctx: Context) { | ||
ctx.body = `Welcome to midwayjs!`; | ||
async index() { | ||
this.ctx.body = `Welcome to midwayjs!`; | ||
} | ||
} |
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