From 62c8e7d314d081318d0c323ba27dd8a7ba009f25 Mon Sep 17 00:00:00 2001 From: Robert McGuinness Date: Mon, 30 Jan 2023 06:27:12 -0500 Subject: [PATCH] Fix customSuccessMessage ts definition (#270) * fix customSuccessMessage ts definition * add tsd for customSuccessMessage --- import.test-d.ts | 5 +++++ index.d.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/import.test-d.ts b/import.test-d.ts index 75b16c5..9144343 100644 --- a/import.test-d.ts +++ b/import.test-d.ts @@ -11,6 +11,11 @@ const { pinoHttp: pinoHttpCjsNamed } = require('.'); const logger = pino(); expectType(pinoHttp({ logger })); +expectType(pinoHttp({ + customSuccessMessage(req, res, responseTime) { + return `${responseTime}` + } +})); expectType(pinoHttpNamed()); expectType(pinoHttpStar.default()); expectType(pinoHttpStar.pinoHttp()); diff --git a/index.d.ts b/index.d.ts index 83114a7..93ab974 100644 --- a/index.d.ts +++ b/index.d.ts @@ -30,7 +30,7 @@ export interface Options extends pino.LoggerOptions { autoLogging?: boolean | AutoLoggingOptions | undefined; customLogLevel?: ((req: IncomingMessage, res: ServerResponse, error?: Error) => pino.LevelWithSilent) | undefined; customReceivedMessage?: ((req: IncomingMessage, res: ServerResponse) => string) | undefined; - customSuccessMessage?: ((req: IncomingMessage, res: ServerResponse) => string) | undefined; + customSuccessMessage?: ((req: IncomingMessage, res: ServerResponse, responseTime: number) => string) | undefined; customErrorMessage?: ((req: IncomingMessage, res: ServerResponse, error: Error) => string) | undefined; customReceivedObject?: ((req: IncomingMessage, res: ServerResponse, val?: any) => any) | undefined; customSuccessObject?: ((req: IncomingMessage, res: ServerResponse, val: any) => any) | undefined;