koa-program/template/controller/index.ts

25 lines
458 B
TypeScript
Raw Permalink Normal View History

import { Context, Next } from "koa";
2021-02-10 03:40:48 +08:00
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",
})
}
}