Skip to content

Commit

Permalink
fix: fix tsconfig in template
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Jun 11, 2019
1 parent a7ef312 commit 1680d29
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 178 deletions.
6 changes: 3 additions & 3 deletions packages/midway-init/boilerplate/boilerplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"midway-ts": {
"package": "midway-ts-boilerplate",
"description": "Simple midway application boilerplate by ts",
"name": "midway typescript template"
"name": "midway standard typescript template"
},
"midway-demo": {
"package": "midway-demo-boilerplate",
"description": "Simple boilerplate for create a midway demo",
"name": "midway demo template"
"description": "Simple example boilerplate for find bug or submit to midway-examples",
"name": "midway mini example template"
},
"midway-ts-ant-design-pro": {
"package": "midway-ts-ant-design-pro-boilerplate",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

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 的包中。
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!`;
}
}
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};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"pretty": true,
"skipLibCheck": true,
"strict": true,
"strictPropertyInitialization": false,
"stripInternal": true,
"target": "ES2017"
},
Expand Down
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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,43 @@ import { IUserService } from '../../lib/interface';
@provide()
@controller('/user')
export class UserController {

@inject()
ctx: Context;

@inject('userService')
service: IUserService;

/**
* GET /user/profile
*/
@get('/profile')
async profile(ctx: Context) {
async profile() {
const res = await this.service.profile();
ctx.body = res.data;
this.ctx.body = res.data;
}

/**
* POST /user/login
*/
@post('/login')
async login(ctx: Context) {
const { username, password } = ctx.query;
async login() {
const { username, password } = this.ctx.query;

if (username === 'admin' && password === 'admin') {
ctx.body = {
this.ctx.body = {
status: 200,
statusText: 'ok',
currentAuthority: 'admin',
};
} else if (username === 'user' && password === 'user') {
ctx.body = {
this.ctx.body = {
status: 200,
statusText: 'ok',
currentAuthority: 'user',
};
} else {
ctx.body = {
this.ctx.body = {
status: 401,
statusText: 'unauthorized',
currentAuthority: 'guest',
Expand All @@ -48,8 +52,8 @@ export class UserController {
* POST /user/register
*/
@post('/register')
async register(ctx: Context) {
ctx.body = {
async register() {
this.ctx.body = {
status: 200,
statusText: 'ok',
currentAuthority: 'user',
Expand All @@ -60,8 +64,8 @@ export class UserController {
* POST /user/logout
*/
@post('/logout')
async logout(ctx: Context) {
ctx.body = {
async logout() {
this.ctx.body = {
status: 200,
statusText: 'ok',
currentAuthority: 'guest',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"pretty": true,
"skipLibCheck": true,
"strict": true,
"strictPropertyInitialization": false,
"stripInternal": true,
"target": "ES2017"
},
Expand Down
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!`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import { IUserService, IUserResult } from '../../interface';
@provide()
@controller('/user')
export class UserController {

@inject()
ctx: Context;

@inject('userService')
service: IUserService;

@get('/:id')
async getUser(ctx: Context): 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};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"pretty": true,
"skipLibCheck": true,
"strict": true,
"strictPropertyInitialization": false,
"stripInternal": true,
"target": "ES2017"
},
Expand Down

0 comments on commit 1680d29

Please sign in to comment.