DefinitelyTyped/types/koa-log/koa-log-tests.ts
Marcel Jackwerth 70eb523a22 feat(koa): Move custom properties into DefaultContext (#39008)
* Move custom properties into DefaultContext

This allows having a strict `Koa<{}, {}>`.

* Fix tests
2019-10-16 11:08:12 -07:00

9 lines
338 B
TypeScript

import Koa = require('koa');
import koaLogger = require('koa-log');
koaLogger.morgan.token('request-ip', ctx => JSON.stringify(ctx.request.ip));
koaLogger.morgan.token('response-body', ctx => JSON.stringify(ctx.body));
const app = new Koa();
app.use(koaLogger(':status :method :url took :response-time ms :request-ip :response-body'));