-
Notifications
You must be signed in to change notification settings - Fork 937
Open
pinojs/pino-std-serializers
#179Description
Hi.
First of all, thanks for this awesome library.
While using it, I was dealing with an issue related to disabling headers on the logged messages and have stumbled up with this issue.
However, when implementing the afore mentioned example, I am getting the error:
Property 'headers' does not exist on type 'ServerResponse<IncomingMessage>'.
Here is my implementation:
export function createHttpLogger(logger: Logger): ReturnType<typeof pinoHttp> {
return pinoHttp({
logger,
serializers: {
req: pino.stdSerializers.wrapRequestSerializer((req) => {
return {
id: req.raw.id,
method: req.raw.method,
path: req.raw.url?.split('?')[0], // Remove query params which might be sensitive
// Allowlist useful headers
headers: {
host: req.raw.headers.host,
'user-agent': req.raw.headers['user-agent'],
referer: req.raw.headers.referer,
},
};
}),
res: pino.stdSerializers.wrapResponseSerializer((res) => {
return {
statusCode: res.raw.statusCode,
// Allowlist useful headers
// TODO: open issue on Github to have this handled by pino-http
headers: {
'content-type': res.raw.headers['content-type'],
'content-length': res.raw.headers['content-length'],
},
};
}),
},
});
}When I log the object res.raw.headers to the console I can clearly see that the property exists in the object.
Am I missing something?
If this is a problem, I would love to open a PR to have it fixed.
Thanks!
Metadata
Metadata
Assignees
Labels
No labels