mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Adding types for hapi-pino.
This commit is contained in:
44
types/hapi-pino/hapi-pino-tests.ts
Normal file
44
types/hapi-pino/hapi-pino-tests.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { Server } from 'hapi';
|
||||
import * as pino from 'pino';
|
||||
import * as HapiPino from 'hapi-pino';
|
||||
|
||||
const pinoLogger = pino();
|
||||
|
||||
const server = new Server();
|
||||
|
||||
server.register({
|
||||
plugin: HapiPino,
|
||||
options: {
|
||||
logPayload: false,
|
||||
logRouteTags: false,
|
||||
stream: process.stdout,
|
||||
prettyPrint: process.env.NODE_ENV !== 'PRODUCTION',
|
||||
levelTags: {
|
||||
trace: 'trace',
|
||||
debug: 'debug',
|
||||
info: 'info',
|
||||
warn: 'warn',
|
||||
error: 'error'
|
||||
},
|
||||
allTags: 'info',
|
||||
serializers: {
|
||||
req: (req: any) => console.log(req)
|
||||
},
|
||||
instance: pinoLogger,
|
||||
logEvents: false,
|
||||
mergeHapiLogData: false,
|
||||
ignorePaths: ['/testRoute'],
|
||||
level: 'debug',
|
||||
redact: ['test.property']
|
||||
}
|
||||
}).then(() => {
|
||||
server.logger().debug('using logger object directly');
|
||||
|
||||
server.route({
|
||||
method: 'GET',
|
||||
path: '/',
|
||||
handler: (request, h) => {
|
||||
request.logger.debug('using logger directly');
|
||||
}
|
||||
});
|
||||
});
|
||||
46
types/hapi-pino/index.d.ts
vendored
Normal file
46
types/hapi-pino/index.d.ts
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
// Type definitions for hapi-pino 5.2
|
||||
// Project: https://github.com/pinojs/hapi-pino#readme
|
||||
// Definitions by: Rodrigo Saboya <https://github.com/saboya>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types='node' />
|
||||
|
||||
import {
|
||||
Plugin,
|
||||
} from 'hapi';
|
||||
import * as pino from 'pino';
|
||||
|
||||
declare module 'hapi' {
|
||||
interface Server {
|
||||
logger: () => pino.Logger;
|
||||
}
|
||||
|
||||
interface Request {
|
||||
logger: pino.Logger;
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace HapiPino {
|
||||
type LogLevels = 'trace' | 'debug' | 'info' | 'warn' | 'error';
|
||||
|
||||
interface Options {
|
||||
logPayload?: boolean;
|
||||
logRouteTags?: boolean;
|
||||
stream?: NodeJS.WriteStream;
|
||||
prettyPrint?: boolean;
|
||||
levelTags?: { [key in LogLevels]: string };
|
||||
allTags?: LogLevels;
|
||||
serializers?: { [key: string]: (param: any) => void};
|
||||
instance?: pino.Logger;
|
||||
logEvents?: string[] | false | null;
|
||||
mergeHapiLogData?: boolean;
|
||||
ignorePaths?: string[];
|
||||
level?: LogLevels;
|
||||
redact?: string[];
|
||||
}
|
||||
}
|
||||
|
||||
declare var HapiPino: Plugin<HapiPino.Options>;
|
||||
|
||||
export = HapiPino;
|
||||
23
types/hapi-pino/tsconfig.json
Normal file
23
types/hapi-pino/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",
|
||||
"hapi-pino-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/hapi-pino/tslint.json
Normal file
1
types/hapi-pino/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user