25 lines
457 B
TypeScript
25 lines
457 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",
|
||
|
})
|
||
|
}
|
||
|
}
|