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

shadow-traffic-mirror

v1.0.3

Published

Enterprise-grade traffic mirroring middleware. Supports Express (Node Streams) and Next.js App Router (Web Standards).

Readme

Shadow Traffic Mirror

An enterprise-grade middleware that mirrors incoming production traffic to a "Shadow" (Staging) environment. It asynchronously compares the responses from both environments and logs mismatches, enabling risk-free testing of new deployments with real-world data.

Features

  • 🚀 Zero Latency: Shadow requests are fired asynchronously ("fire and forget"); user response time is unaffected.
  • Dual Runtime Support:
    • Node.js Streams: Optimized for Express/Fastify (event spies without breaking body-parser).
    • Web Standards: Optimized for Next.js App Router & Edge Runtimes (using fetch and Request.clone()).
  • 🛡️ Smart Diffing: Recursively ignores volatile fields (e.g., timestamp, trace_id) to prevent false positives.
  • 📦 ESM Native: Built for modern JavaScript stacks (ESM2025 ready).

Installation

npm install shadow-traffic-mirror

Usage: Next.js (App Router)

Designed for modern app/api routes using Web Standard Request/Response objects.

File: app/api/users/route.tsTypeScriptimport { NextResponse } from 'next/server';
import { withShadow } from 'shadow-traffic-mirror/next'; // Note the /next import

// 1. Define your normal Route Handler
async function POST_HANDLER(req: Request) {
  const body = await req.json();
  // ... database logic ...
  return NextResponse.json({ status: 'success', id: 123, timestamp: Date.now() });
}


export const POST = withShadow(POST_HANDLER, {
  target: '[https://staging-api.yourcompany.com](https://staging-api.yourcompany.com)',
  ignoreKeys: ['timestamp', 'trace_id', '_id']
});

Usage: Express / Node.js

Designed for traditional Node.js servers using Streams. This middleware safely "spies" on the stream without consuming it, ensuring compatibility with body-parser.

File: server.jsJavaScriptimport express from 'express';
import shadow from 'shadow-traffic-mirror'; // Default import

const app = express();

// 1. Register middleware BEFORE body-parser
app.use(shadow({
  target: '[https://staging-api.yourcompany.com](https://staging-api.yourcompany.com)',
  ignoreKeys: ['timestamp', 'requestId']
}));

// 2. Normal middleware & routes
app.use(express.json());

app.post('/api/data', (req, res) => {
  res.json({ status: 'success', timestamp: Date.now() });
});

app.listen(3000);

Configuration Options

Option | Type | Default | Description --- | --- | --- | --- target | string | Required | The base URL of the Shadow/Staging environment (e.g., https://staging.api.com). ignoreKeys | string[] | [] | List of JSON keys to exclude from the comparison (supports deep nesting).