UNPKG

@thisisagile/easy-express

Version:

Straightforward library for building domain-driven microservice architectures

8 lines (6 loc) 338 B
import express from 'express'; import { ctx, HttpHeader, toUuid } from '@thisisagile/easy'; export const correlation = (req: express.Request, res: express.Response, next: express.NextFunction): void => { res.setHeader(HttpHeader.Correlation, (ctx.request.correlationId = req?.header(HttpHeader.Correlation) ?? toUuid())); next(); };