CorrelationOptions
Defined in: options/correlation.options.ts:49
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 passes the rules
configureCorrelation sets, by default at most
DEFAULT_CORRELATION_ID_MAX_LENGTH characters matching
DEFAULT_CORRELATION_ID_PATTERN; otherwise a local ID is used.
maxLength and validateIncoming replace those rules for this middleware.
Examples
Section titled “Examples”Accept only UUIDs from clients
Ignore client IDs completely and always generate/use the local ID
Properties
Section titled “Properties”acceptIncoming?
Section titled “acceptIncoming?”
optionalacceptIncoming?:boolean
Defined in: options/correlation.options.ts:67
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”header?
Section titled “header?”
optionalheader?:string|false
Defined in: options/correlation.options.ts:58
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”maxLength?
Section titled “maxLength?”
optionalmaxLength?:number
Defined in: options/correlation.options.ts:83
Maximum accepted incoming correlation-ID length. Longer values are discarded and replaced by the locally resolved/generated ID.
Default
Section titled “Default”the maxLength of configureCorrelation, 128 unless configured
trimIncoming?
Section titled “trimIncoming?”
optionaltrimIncoming?:boolean
Defined in: options/correlation.options.ts:75
Trim surrounding whitespace before optional length/custom validation and before storing/echoing the ID.
Default
Section titled “Default”validateIncoming?
Section titled “validateIncoming?”
optionalvalidateIncoming?: (correlationId) =>boolean
Defined in: options/correlation.options.ts:100
Validation predicate for incoming IDs; replaces the validateIncoming of
configureCorrelation, by default the DEFAULT_CORRELATION_ID_PATTERN
check. Returning false (or throwing) rejects the incoming value and falls
back to the local correlation ID. maxLength still applies, and the
predicate sees only values of printable ASCII (0x20 to 0x7E) that neither
start nor end with a space.
Parameters
Section titled “Parameters”correlationId
Section titled “correlationId”string
Returns
Section titled “Returns”boolean