{"id":28936278,"url":"https://github.com/orca-scan/express-deprecator","last_synced_at":"2026-04-24T11:36:39.072Z","repository":{"id":300459764,"uuid":"1005457632","full_name":"orca-scan/express-deprecator","owner":"orca-scan","description":"Drop deprecated API traffic","archived":false,"fork":false,"pushed_at":"2025-06-21T20:31:20.000Z","size":158,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-21T20:34:10.593Z","etag":null,"topics":["express","rest-api"],"latest_commit_sha":null,"homepage":"https://orcascan.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orca-scan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-20T09:01:32.000Z","updated_at":"2025-06-21T20:31:23.000Z","dependencies_parsed_at":"2025-06-21T20:44:46.949Z","dependency_job_id":null,"html_url":"https://github.com/orca-scan/express-deprecator","commit_stats":null,"previous_names":["orca-scan/express-deprecator"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/orca-scan/express-deprecator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orca-scan%2Fexpress-deprecator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orca-scan%2Fexpress-deprecator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orca-scan%2Fexpress-deprecator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orca-scan%2Fexpress-deprecator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orca-scan","download_url":"https://codeload.github.com/orca-scan/express-deprecator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orca-scan%2Fexpress-deprecator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261358697,"owners_count":23146674,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express","rest-api"],"created_at":"2025-06-22T20:08:14.040Z","updated_at":"2026-04-24T11:36:39.067Z","avatar_url":"https://github.com/orca-scan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# express-deprecator\n\n[![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)\n[![npm](https://img.shields.io/npm/v/express-deprecator)](https://www.npmjs.com/package/express-deprecator)\n[![license](https://img.shields.io/github/license/orca-scan/express-deprecator)](https://github.com/orca-scan/express-deprecator/blob/master/LICENSE)\n\nDrop deprecated API traffic - cleanly, safely, and without legacy routes.\n\n**Why?** over time, APIs collect old clients, outdated apps, and unsupported versions. `express-deprecator` helps you phase them out **without bloating your app logic**.\n\n\n**Features**\n* No routes needed – matches requests before your logic runs\n* Fast + lightweight – no dependencies\n* Match on method, url, headers, query, or body\n* Regex support – use \"/^v1\\\\./\" to match patterns\n* Not a security layer – built for hygiene, not defense\n* Keeps your codebase clean – no more if (version === '0.0.0')\n\n## Install\n\n```bash\nnpm install express-deprecator\n```\n\n## Usage\n\n```js\nconst express = require('express');\nconst expressDeprecator = require('express-deprecator');\nconst app = express();\n\napp.use(express.json());\napp.use(expressDeprecator()); // auto-loads ./deprecations.json\n```\n\n### Example rule\n\nBlock outdated client versions in request body:\n\n```json\n[\n  {\n    \"description\": \"Deprecate old client (v0.0.0)\",\n    \"method\": \"POST\",\n    \"url\": \"/api/submit\",\n    \"body\": {\n      \"lib.version\": \"0.0.0\"\n    },\n    \"status\": 426,\n    \"response\": {\n      \"error\": \"This version of the client is no longer supported\",\n      \"upgrade\": \"https://example.com/docs/v2\"\n    }\n  }\n]\n```\n\nWhen a request like this is received:\n\n```bash\nPOST /api/submit\nContent-Type: application/json\n\n{\n  \"lib\": {\n    \"version\": \"0.0.0\"\n  }\n}\n```\n\nIt’s automatically blocked with:\n\n```bash\nHTTP/1.1 426 Upgrade Required\nContent-Type: application/json\n\n{\n  \"error\": \"This version of the client is no longer supported\",\n  \"upgrade\": \"https://example.com/docs/v2\"\n}\n```\n\n### Rule syntax\n\n* Match on any combination of:\n  * `method`: \"GET\", \"POST\", etc\n  * `url`: exact path or regex _(e.g. \"/^\\\\/api\\\\//\")_\n  * `headers`: header values _(supports regex)_\n  * `query`: supports nested JSON keys strings _(e.g. \"payload.device.version\")_\n  * `body`: supports nested keys in dot notation\n* Regex matches must be strings wrapped in `/`...`/`\n* By default, unmatched requests are passed to your routes\n* Matched requests are ended early with the given status and response\n\n### What it’s not for\n\nThis 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.\n\n### Why not just use code?\n\nYou could do this in a route:\n\n```js\nif (req.body?.lib?.version === '0.0.0') {\n  return res.status(426).json({ error: 'Deprecated version' });\n}\n```\n\nBut that logic sticks around forever. express-deprecator lets you:\n* manage deprecations in a JSON file _(not source code)_\n* remove rules once traffic fades\n* keep your API routes lean and focused\n\n## License\n\n[MIT License](LICENSE) © Orca Scan - a [barcode app](https://orcascan.com) with simple [barcode tracking APIs](https://orcascan.com/guides?tag=for-developers).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forca-scan%2Fexpress-deprecator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forca-scan%2Fexpress-deprecator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forca-scan%2Fexpress-deprecator/lists"}