mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 11:57:33 +08:00
a293cc2d5e/test/context/state.js (L16)
and the ```server.listen([port][, hostname][, backlog][, callback])``` all parameters is options
https://nodejs.org/api/net.html#net_server_listen_port_hostname_backlog_callback
24 lines
446 B
TypeScript
24 lines
446 B
TypeScript
/// <reference path="koa.d.ts" />
|
|
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();
|