Skip to content

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

@tal-rofe98

Description

@tal-rofe98

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions