Files
DefinitelyTyped/types/koa/koa-tests.ts
2017-03-24 14:27:52 -07:00

24 lines
413 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`);
ctx.assert(true, 404, 'Yep!');
});
});
// response
app.use(ctx => {
ctx.body = "Hello World";
});
app.listen(3000);
const server = app.listen();