Replace express-request-id with an inline middleware
org.openrewrite.node.migrate.express-request-id.replace-express-request-idArtifact@openrewrite/recipes-nodejsReplaces the express-request-id middleware factory with an equivalent inline middleware that reuses an incoming X-Request-Id header or generates an id with randomUUID() from node:crypto (Node.js 14.17+), stores it on the request and echoes it in the response header. The setHeader, headerName, attributeName and generator options carry over; calls with other options, or options that aren't literals, are left alone. attributeName is honored as in 1.x; versions 2 and 3 ignore it and always set req.id. In TypeScript the id is set with Object.assign so no Request augmentation is needed, and a middleware stored in a variable is typed as Express's RequestHandler.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.node.migrate.express-request-id.replace-express-request-idIf the recipe isn’t available locally, install it with:
mod config recipes npm install @openrewrite/recipes-nodejs