Stop phantom endpoints from haunting your codebase.
Ghostbusters is a lightweight JavaScript utility designed to identify "ghost routes" (unused or broken endpoints) in React-to-Express routing. By integrating directly into your Git workflow, it ensures that dead code is eliminated before it ever hits production.
- ESM Support: Optimized for modern environments using ECMAScript Modules to provide a lightweight and efficient footprint.
- Git Hooks: Leverages Husky to automate code quality checks, catching ghost routes at the point of commit.
- Dedicated CLI: Includes a dedicated entry point for terminal-based route detection.
Ghostbusters analyzes your codebase to identify discrepancies between your frontend API calls and backend routes. It specifically flags:
- Broken Calls: Requests in your frontend that point to routes that don't exist in your backend.
- Node.js
- npm
npm install @ghostbusters/cli --save-devCreate a ghostbusters.config.js in your project root to customize scan directories and ignore patterns.
// ghostbusters.config.js
export default {
frontend: ["./src/client", "./src/components"],
backend: ["./src/server", "./src/api"],
ignore: ["node_modules", "dist", "*.test.js"]
};Add a script to your package.json for easy scanning.
scripts: {
"ghostbusters": "ghostbusters scan --frontend ./src/client --backend ./src/server"
}# Basic scan
npx ghostbusters
# options:
Run without console output
-s or --silent
# Output results as a JSON object for custom tooling
-j, --json.husky/: Pre-commit hook configurationssrc/: Core logic & CLI entry pointtest/: Quality control test suitesscripts/: Development automation helperspackage.json: ESM configuration & dependencies
We use a dedicated test suite to ensure the detection logic is accurate.
npm testThis project is licensed under the MIT License.