mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
21 lines
348 B
TypeScript
21 lines
348 B
TypeScript
|
|
import * as Koa from "koa";
|
|
|
|
const app = new Koa();
|
|
|
|
app.use((ctx, next) => {
|
|
const start: any = new Date();
|
|
return next().then(() => {
|
|
const end: any = new Date();
|
|
const ms = end - start;
|
|
console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
|
|
});
|
|
});
|
|
|
|
// response
|
|
app.use(ctx => {
|
|
ctx.body = "Hello World";
|
|
});
|
|
|
|
app.listen(3000);
|