Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tal-rofe98 opened this issue Apr 30, 2024 · 1 comment

Comments

@tal-rofe98
Copy link

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?

@jsumners
Copy link
Member

jsumners commented May 6, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants