CorrelationOptions
Defined in: options/correlation.options.ts:48
Correlation ID configuration consumed by httpCorrelation.
The middleware is registered explicitly by the application. For non-HTTP
transports (Bull, RabbitMQ, etc.), use runWithCorrelationId() directly in
your processor/handler.
An incoming header value is accepted only when it is at most
DEFAULT_CORRELATION_ID_MAX_LENGTH characters and matches
DEFAULT_CORRELATION_ID_PATTERN; otherwise a local ID is used.
maxLength and validateIncoming replace these defaults.
Examples
Section titled “Examples”// Custom header name{ header: 'x-request-id' }
// `header: false` selects the default header; it does not disable the middleware.{ header: false } // uses 'x-correlation-id'Accept only UUIDs from clients
{ maxLength: 36, trimIncoming: true, validateIncoming: (id) => /^[0-9a-f-]{36}$/i.test(id),}Ignore client IDs completely and always generate/use the local ID
{ acceptIncoming: false }Properties
Section titled “Properties”acceptIncoming?
Section titled “acceptIncoming?”
optionalacceptIncoming?:boolean
Defined in: options/correlation.options.ts:66
Whether a non-empty incoming correlation ID may be used.
Set to false when correlation IDs are internal-only and should never be
controlled by the HTTP client.
Default
Section titled “Default”trueheader?
Section titled “header?”
optionalheader?:string|false
Defined in: options/correlation.options.ts:57
HTTP header name to extract the correlation ID from.
A valid, non-empty HTTP field-name string selects that header. Invalid
strings throw during middleware construction. Any non-string value, including false and
undefined, makes the middleware use the default x-correlation-id header.
Default
Section titled “Default”'x-correlation-id'maxLength?
Section titled “maxLength?”
optionalmaxLength?:number
Defined in: options/correlation.options.ts:82
Maximum accepted incoming correlation-ID length. Longer values are discarded and replaced by the locally resolved/generated ID.
Default
Section titled “Default”128trimIncoming?
Section titled “trimIncoming?”
optionaltrimIncoming?:boolean
Defined in: options/correlation.options.ts:74
Trim surrounding whitespace before optional length/custom validation and before storing/echoing the ID.
Default
Section titled “Default”falsevalidateIncoming?
Section titled “validateIncoming?”
optionalvalidateIncoming?: (correlationId) =>boolean
Defined in: options/correlation.options.ts:97
Validation predicate for incoming IDs; replaces the default
DEFAULT_CORRELATION_ID_PATTERN check. Returning false (or
throwing) rejects the incoming value and falls back to the local
correlation ID. maxLength still applies.
Parameters
Section titled “Parameters”correlationId
Section titled “correlationId”string
Returns
Section titled “Returns”boolean
Example
Section titled “Example”{ validateIncoming: (id) => /^[A-Za-z0-9._-]+$/.test(id),}