mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Merge pull request #28509 from sjmcdowall/master
Add definitions for koa-bunyan-logger -- attempt 2
This commit is contained in:
Vendored
+21
@@ -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);
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user