mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-29 09:41:45 +00:00
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:
Vendored
+19
@@ -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);
|
||||
@@ -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