Attempt number 2 for PR

Ok -- cleaned up a lot of stuff -- but lost my master branch etc. so started over. Sorry!
This commit is contained in:
Steven McDowall
2018-08-29 15:27:12 -04:00
parent ec6a6ef299
commit 85de4c3615
4 changed files with 55 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
// 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 * as Logger from 'bunyan';
export default function(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 * as Koa from 'koa';
import koaBunyanLogger from '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" }