Merge pull request #28509 from sjmcdowall/master

Add definitions for koa-bunyan-logger -- attempt 2
This commit is contained in:
Armando Aguirre
2018-09-04 11:00:01 -07:00
committed by GitHub
4 changed files with 57 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for koa-bunyan-logger 2.0
// Project: https://github.com/koajs/bunyan-logger
// Definitions by: Steven McDowall <https://github.com/sjmcdowall>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { Middleware } from 'koa';
import Logger = require('bunyan');
export = koaBunyanLogger;
declare function koaBunyanLogger(logger?: Logger): Middleware;
// Extend the Koa context to add the logger..
declare module 'koa' {
// tslint:disable-next-line: interface-name
interface BaseContext {
log: Logger;
}
}
@@ -0,0 +1,12 @@
import Koa = require('koa');
import koaBunyanLogger = require('koa-bunyan-logger');
const app = new Koa();
app.use(koaBunyanLogger());
app.use(async (ctx, next) => {
ctx.log.info('Got a request from %s for %s', ctx.request.ip, ctx.path);
await next();
});
app.listen(8000);
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"koa-bunyan-logger-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }