elseware-nodejs 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5453,6 +5453,26 @@ var RequestContext = class {
5453
5453
  }
5454
5454
  };
5455
5455
 
5456
+ // src/networking/middleware/RequestContextMiddleware.ts
5457
+ function createRequestContextMiddleware(options = {}) {
5458
+ const {
5459
+ correlationHeaderName = "X-Correlation-Id",
5460
+ exposeHeader = true
5461
+ } = options;
5462
+ return (req, res, next) => {
5463
+ const correlationId = req.header(correlationHeaderName) ?? CorrelationId.generate();
5464
+ if (exposeHeader) {
5465
+ res.setHeader(correlationHeaderName, correlationId);
5466
+ }
5467
+ RequestContext.run(
5468
+ {
5469
+ correlationId
5470
+ },
5471
+ () => next()
5472
+ );
5473
+ };
5474
+ }
5475
+
5456
5476
  // src/networking/observability/TracingHeaders.ts
5457
5477
  var TracingHeaders = class {
5458
5478
  static build() {
@@ -6355,6 +6375,7 @@ exports.ZodValidator = ZodValidator;
6355
6375
  exports.authMiddleware = authMiddleware;
6356
6376
  exports.createAllowedOrigins = createAllowedOrigins;
6357
6377
  exports.createCorsOptions = createCorsOptions;
6378
+ exports.createRequestContextMiddleware = createRequestContextMiddleware;
6358
6379
  exports.days = days;
6359
6380
  exports.errorToString = errorToString;
6360
6381
  exports.hours = hours;