npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@evanion/nestjs-correlation-id

v2.1.1

Published

Correlation ID middleware for NestJS. Carries one id from the incoming request through everything it awaits and onto outgoing HTTP calls, so log lines across services line up.

Readme

@evanion/nestjs-correlation-id

Transparent request tracing across your NestJS microservices.

Debugging distributed systems is like solving a puzzle with pieces from three different boxes when a single user action triggers a chain of services and you are forced to hunt through fragmented logs by guessing timestamps. @evanion/nestjs-correlation-id solves this by attaching a correlation ID to every incoming request and forwarding it through your service chain.

To see how IDs are tracked without being passed as function arguments, the following example uses CorrelationService.run to simulate the request context that the middleware normally opens.

import { CorrelationService } from '@evanion/nestjs-correlation-id';

const lines: string[] = [];
const logger = { log: (line: string) => lines.push(line) };

class OrdersService {
  constructor(
    private readonly correlationService: CorrelationService,
    private readonly logger: { log(line: string): void },
  ) {}

  place(order: string) {
    const id = this.correlationService.getCorrelationId();
    this.logger.log(`Placing ${order} for request ${id}`);
  }
}

const correlation = new CorrelationService({
  header: 'X-Correlation-Id',
  generator: () => crypto.randomUUID(),
});
const orders = new OrdersService(correlation, logger);

correlation.run('storefront-4f1c9a', () => orders.place('order-2026-0042'));
orders.place('order-2026-0043');

lines; // -> ['Placing order-2026-0042 for request storefront-4f1c9a', 'Placing order-2026-0043 for request undefined']

Capabilities

@evanion/nestjs-correlation-id uses AsyncLocalStorage to ensure IDs remain isolated between concurrent requests and survive await boundaries.

  • Forwarding: An HttpService registered with withCorrelation() sends the current ID on every outgoing call through an Axios interceptor.
  • Context-Aware: The correlation ID is available anywhere in the request chain—guards, interceptors, controllers, and services.
  • Fully Configurable: Customize your header name (X-Correlation-Id), ID generator, and validation logic.
  • Compatibility: The middleware runs on NestJS's default Express platform.

Requirements and Installation

The package is ESM only and requires Node 20 or newer. It uses tslib as its only runtime dependency, with @nestjs/common 12 as a peer dependency and @nestjs/axios 12 as an optional dependency for forwarding.

npm install @evanion/nestjs-correlation-id

Documentation

For the full API reference and integration guides, visit our documentation site:

👉 docs.evanion.com/nestjs-correlation-id

License

MIT