Skip to main content

Class: CorrelationMiddleware

Defined in: packages/common/src/nest/correlation.middleware.ts:20

Opens a correlation context for each HTTP request and echoes the id in the response header, so success carries it as well as failure (chapter 30).

Adopts a well-formed inbound x-correlation-id, otherwise mints one. Works on the raw Node request, so it is adapter-neutral (Fastify's middleware layer and Express alike). Register with consumer.apply(CorrelationMiddleware).forRoutes('*'). Does nothing about tenantId: that is known only after authentication, and the caller adds it with enrichContext.

Implements​

  • NestMiddleware

Constructors​

Constructor​

new CorrelationMiddleware(): CorrelationMiddleware

Returns​

CorrelationMiddleware

Methods​

use()​

use(req, res, next): void

Defined in: packages/common/src/nest/correlation.middleware.ts:22

Nest's middleware entry point.

Parameters​

req​

IncomingMessage

res​

ServerResponse

next​

(error?) => void

Returns​

void

Implementation of​

NestMiddleware.use