mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add types for express-bunyan-logger module.
This commit is contained in:
parent
420e0d5d29
commit
c8f7a59cc8
24
types/express-bunyan-logger/express-bunyan-logger-tests.ts
Normal file
24
types/express-bunyan-logger/express-bunyan-logger-tests.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import Bunyan = require('bunyan');
|
||||
import expressBunyan = require('express-bunyan-logger');
|
||||
|
||||
// works with no options
|
||||
const middleware = expressBunyan({});
|
||||
const middleware2 = expressBunyan.errorLogger({});
|
||||
|
||||
// format accepts both string and function
|
||||
const middleware3 = expressBunyan({
|
||||
format: ':name'
|
||||
});
|
||||
const middleware4 = expressBunyan({
|
||||
format(meta: any) {
|
||||
return 'foo';
|
||||
}
|
||||
});
|
||||
|
||||
// works when provided a bunyan logger
|
||||
const logger = Bunyan.createLogger({
|
||||
name: 'myLogger'
|
||||
});
|
||||
const middleware5 = expressBunyan({
|
||||
logger
|
||||
});
|
||||
34
types/express-bunyan-logger/index.d.ts
vendored
Normal file
34
types/express-bunyan-logger/index.d.ts
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
// Type definitions for express-bunyan-logger 1.3
|
||||
// Project: https://github.com/villadora/express-bunyan-logger
|
||||
// Definitions by: Shrey Jain <https://github.com/shreyjain1994>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import Bunyan = require('bunyan');
|
||||
import express = require('express');
|
||||
|
||||
export = Factory;
|
||||
|
||||
declare function Factory(options?: Factory.Options): express.RequestHandler;
|
||||
|
||||
declare namespace Factory {
|
||||
type FormatFunction = (meta: any) => string;
|
||||
type IncludesFunction = (req: express.Request, res: express.Response) => any;
|
||||
type RequestIdGenFunction = (req: express.Request) => string;
|
||||
type LevelFunction = (status: number, err: Error | null, meta: any) => string;
|
||||
|
||||
interface Options {
|
||||
logger?: Bunyan;
|
||||
format?: string | FormatFunction;
|
||||
parseUA?: boolean;
|
||||
levelFn?: LevelFunction;
|
||||
includesFn?: IncludesFunction;
|
||||
excludes?: string[];
|
||||
obfuscate?: string[];
|
||||
obfuscatePlaceholder?: string;
|
||||
serializers?: { [field: string]: Bunyan.Serializer };
|
||||
immediate?: boolean;
|
||||
genReqId?: RequestIdGenFunction;
|
||||
}
|
||||
|
||||
function errorLogger(options?: Options): express.ErrorRequestHandler;
|
||||
}
|
||||
23
types/express-bunyan-logger/tsconfig.json
Normal file
23
types/express-bunyan-logger/tsconfig.json
Normal 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",
|
||||
"express-bunyan-logger-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/express-bunyan-logger/tslint.json
Normal file
1
types/express-bunyan-logger/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user