Installation
npm install --save @types/pino-http
Summary
This package contains type definitions for pino-http (https://github.com/pinojs/pino-http#readme).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/pino-http.
import { IncomingMessage, ServerResponse } from "http";
import { DestinationStream, Level, Logger, LoggerOptions } from "pino";
export = PinoHttp;
declare function PinoHttp(opts?: PinoHttp.Options, stream?: DestinationStream): PinoHttp.HttpLogger;
declare function PinoHttp(stream?: DestinationStream): PinoHttp.HttpLogger;
declare namespace PinoHttp {
interface HttpLogger {
(req: IncomingMessage, res: ServerResponse, next?: () => void): void;
logger: Logger;
}
type ReqId = number | string | object;
interface Options extends LoggerOptions {
logger?: Logger | undefined;
genReqId?: GenReqId | undefined;
useLevel?: Level | undefined;
stream?: DestinationStream | undefined;
autoLogging?: boolean | AutoLoggingOptions | undefined;
customLogLevel?: ((res: ServerResponse, error: Error) => Level) | undefined;
customSuccessMessage?: ((res: ServerResponse) => string) | undefined;
customErrorMessage?: ((error: Error, res: ServerResponse) => string) | undefined;
customAttributeKeys?: CustomAttributeKeys | undefined;
wrapSerializers?: boolean | undefined;
reqCustomProps?: ((req: IncomingMessage, res: ServerResponse) => object) | undefined;
quietReqLogger?: boolean | undefined;
}
interface GenReqId {
(req: IncomingMessage): ReqId;
}
interface AutoLoggingOptions {
ignore?: (req: IncomingMessage) => boolean;
ignorePaths?: Array<string | RegExp> | undefined;
getPath?: ((req: IncomingMessage) => string | undefined) | undefined;
}
interface CustomAttributeKeys {
req?: string | undefined;
res?: string | undefined;
err?: string | undefined;
reqId?: string | undefined;
responseTime?: string | undefined;
}
const startTime: unique symbol;
}
declare module "http" {
interface IncomingMessage {
id: PinoHttp.ReqId;
log: Logger;
}
interface ServerResponse {
err?: Error | undefined;
}
interface OutgoingMessage {
[PinoHttp.startTime]: number;
}
}
Additional Details
- Last updated: Tue, 07 Nov 2023 09:09:39 GMT
- Dependencies: @types/pino
Credits
These definitions were written by Christian Rackerseder, Jeremy Forsythe, Griffin Yourick, and Jorge Barnaby.