koa-program/template/controller/index.ts
Titor-Z 08cbf8bec4 2.0
- 使用ora 和 prompts
- 拆分结构代码,功能更加独立
- 独立的结构,可以给予其他cli作为脚手架底层使用
2021-02-17 01:49:07 +08:00

25 lines
458 B
TypeScript

import { Context, Next } from "koa";
export class Index {
static async index(ctx: Context, next: Next): Promise<any> {
ctx.body = "This is Home!"
await next()
}
static async json(ctx: Context, next: Next): Promise<any> {
ctx.type = "json"
ctx.body = {
code: "200",
message: "This is Home!",
}
await next()
}
static async view(ctx: Context) {
await ctx.render("index", {
name: "titor",
})
}
}