@relab/fastify-correlation-id
v1.0.11
Published
Fastify plugin to store and retrieve correlation IDs.
Downloads
80
Readme
@relab/fastify-correlation-id
Fastify plugin to store and retrieve correlation IDs.
The plugin retrieves the X-Correlation-ID
header (or any other desired header) from the request and makes it accessible throughout the application code. It also propagates the header to the response.
Requirements
- Node 18+
- Fastify 4+
Installation
NPM
npm install --save @relab/fastify-correlation-id
PNPM
pnpm add @relab/fastify-correlation-id
Usage
import Fastify from 'fastify'
import { CorrelationId } from '@relab/fastify-correlation-id'
const fastify = Fastify()
.register(CorrelationId, {
header: 'X-Correlation-ID', // optional
skipResponseHeader: true, // optional
})
Configuration
There are some environment variables used to configure logger.
| Option | Description | Default |
|-----------------------|----------------------------------------------------------------------------|--------------------|
| header
| Header name for correlation ID. | X-Correlation-ID
|
| skipResponseHeader
| If set to true
, it will not propagate correlation ID to response header. | false
|
License
Released under MIT by Sergey Zwezdin.