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 🙏

© 2025 – Pkg Stats / Ryan Hefner

express-deprecator

v1.0.1

Published

[![Tests](https://github.com/orca-scan/express-deprecator/actions/workflows/ci.yml/badge.svg)](https://github.com/orca-scan/express-deprecator/actions/workflows/ci.yml) [![npm](https://img.shields.io/npm/v/express-deprecator)](https://www.npmjs.com/packag

Readme

express-deprecator

Tests npm license

Drop deprecated API traffic - cleanly, safely, and without legacy routes.

Why? over time, APIs collect old clients, outdated apps, and unsupported versions. express-deprecator helps you phase them out without bloating your app logic.

Features

  • No routes needed – matches requests before your logic runs
  • Fast + lightweight – no dependencies
  • Match on method, url, headers, query, or body
  • Regex support – use "/^v1\./" to match patterns
  • Not a security layer – built for hygiene, not defense
  • Keeps your codebase clean – no more if (version === '0.0.0')

Install

npm install express-deprecator

Usage

const express = require('express');
const expressDeprecator = require('express-deprecator');
const app = express();

app.use(express.json());
app.use(expressDeprecator()); // auto-loads ./deprecations.json

Example rule

Block outdated client versions in request body:

[
  {
    "description": "Deprecate old client (v0.0.0)",
    "method": "POST",
    "url": "/api/submit",
    "body": {
      "lib.version": "0.0.0"
    },
    "status": 426,
    "response": {
      "error": "This version of the client is no longer supported",
      "upgrade": "https://example.com/docs/v2"
    }
  }
]

When a request like this is received:

POST /api/submit
Content-Type: application/json

{
  "lib": {
    "version": "0.0.0"
  }
}

It’s automatically blocked with:

HTTP/1.1 426 Upgrade Required
Content-Type: application/json

{
  "error": "This version of the client is no longer supported",
  "upgrade": "https://example.com/docs/v2"
}

Rule syntax

  • Match on any combination of:
    • method: "GET", "POST", etc
    • url: exact path or regex (e.g. "/^\/api\//")
    • headers: header values (supports regex)
    • query: supports nested JSON keys strings (e.g. "payload.device.version")
    • body: supports nested keys in dot notation
  • Regex matches must be strings wrapped in /.../
  • By default, unmatched requests are passed to your routes
  • Matched requests are ended early with the given status and response

What it’s not for

This is not intended to be used as a Web Application Firewall, authentication or security layer. Use it to keep your API maintainable, not to protect it from abuse.

Why not just use code?

You could do this in a route:

if (req.body?.lib?.version === '0.0.0') {
  return res.status(426).json({ error: 'Deprecated version' });
}

But that logic sticks around forever. express-deprecator lets you:

  • manage deprecations in a JSON file (not source code)
  • remove rules once traffic fades
  • keep your API routes lean and focused

License

MIT License © Orca Scan - a barcode app with simple barcode tracking APIs.