Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const loggerPlugin = ({ dev, requestLogger }: Options): any => {
const pinoOptions = dev ? {
prettyPrint: true,
prettifier: pinoPretty,
level: 'trace',
} : {};
const logger = pino((pinoOptions as any));
const pinoHandler = pinoHTTP({
logger,
});
return (fn: any): any => async (req: IM, res: SR): AP => {
if (requestLogger) {
pinoHandler(req, res);
}
return fn(req, res);
};
};