dead-api-scanner
v1.1.4
Published
Scans backend routes and frontend usage to find unused (dead) APIs in your fullstack project.
Downloads
4
Maintainers
Readme
🧠 Dead API Scanner
A CLI + programmatic tool to detect unused (dead) REST API endpoints in fullstack JavaScript/TypeScript projects.
Use it to clean up outdated routes, reduce backend bloat, and maintain high-quality code.
🚀 Features
- ✅ Scans Express-style backend routes (
app.get,router.post, etc.) - ✅ Detects frontend usage (
fetch,axios,axios.create) - ✅ Supports dynamic route patterns (e.g.
/api/user/:id) - ✅ Lists unused (dead) backend API endpoints
- ✅ CLI and programmatic usage
- ✅ JSON output for automation
- ✅ Custom ignore list support (
--ignore=/api/ping,...)
📦 Installation
Install globally or use directly with npx:
npm install -g dead-api-scanner
# or
npx dead-api-scanner ./backend ./frontend
🧪 CLI Usage
The ./backend ./frontend arguments represent the paths to your server (API routes) and client (API usage) code.
npx dead-api-scanner ./backend ./frontend
🔍 Dead API Scanner Report ────────────────────────────── 📁 Backend routes scanned : 12 📦 Frontend API used : 9 🗑️ Dead APIs found : 3 ──────────────────────────────
❌ Dead Routes:
- GET /api/users/all
- POST /api/admin/create
- DELETE /api/order/456
npx dead-api-scanner ./backend ./frontend --json
npx dead-api-scanner ./backend ./frontend --ignore=/api/health,/api/pingSuggestion:
```bash
# Output JSON for CI/CD
npx dead-api-scanner ./backend ./frontend --json
# Ignore specific endpoints
npx dead-api-scanner ./backend ./frontend --ignore=/api/health,/api/ping
📁 Config File Support
You can configure paths and ignored routes using a .deadapirc file in your project root:
{
"backend": "./backend",
"frontend": "./frontend",
"ignore": ["/api/health", "/api/ping"]
}📦 Programmatic Usage
import { findDeadApis } from 'dead-api-scanner';
const result = findDeadApis('./backend', './frontend', ['/api/health']);
console.log(result);
/*
{
total: 5,
used: 3,
dead: [
{ method: 'GET', route: '/api/users/all' },
{ method: 'POST', route: '/api/admin/create' }
]
}
*/🛠 Supported Patterns
app.get('/api/user', ...)
router.post('/api/login', ...)
fetch('/api/user')
axios.get('/api/user')
api.post('/users') // via axios.create({ baseURL: '/api' })📄 License
MIT © 2024 iamxerrycan
Made with ❤️ to help developers delete unused code and sleep better.
