pino-http icon indicating copy to clipboard operation
pino-http copied to clipboard

How to inject request to the HttpLogger in the express middleware example?

Open tal-rofe98 opened this issue 1 year ago • 1 comments

I want to follow this example: https://www.npmjs.com/package/pino-http#use-as-express-middleware

but I also want to provide the logger() call with the request object. Something like this:

const logger = require('pino-http')

const app = express()

app.use((req) => logger(req))

But it does not work (it crashes my server). Is it even possible?

tal-rofe98 avatar Apr 30 '24 14:04 tal-rofe98

Please provide a minimal reproducible example. Doing so will help us diagnose your issue. It should be the bare minimum code needed to trigger the issue, and easily runnable without any changes or extra code.

You may use a GitHub repository to host the code if it is too much to fit in a code block (or two).

jsumners avatar May 06 '24 21:05 jsumners