@bhaskardey772/auto-relay
v1.0.0
Published
CLI tool to auto-discover Express.js routes and explore them in a browser — no changes needed in your app.
Maintainers
Readme
auto-relay
A CLI tool that auto-discovers your Express.js routes and lets you explore and test them in the browser — no changes needed in your app code.
Install the package, run two commands, done.
Current support: Node.js + Express.js
Install
npm install --save-dev @bhaskardey772/auto-relayUsage
Step 1 — Initialize config
npx auto-relay initThis creates auto-relay.config.js in your project root:
module.exports = {
rootDir: './', // directory to scan for routes
port: 4000, // port for the relay explorer
baseUrl: 'http://localhost:3000', // your running Express app's URL
exclude: [],
title: 'Auto Relay',
};Step 2 — Start your app as usual
node app.js # or npm start, nodemon, etc.Step 3 — Start the relay
npx auto-relay startOpen http://localhost:4000 in your browser — all your routes are there, ready to test.
What you get
- Sidebar — all Express routes auto-detected, grouped by file or HTTP method
- Filter & group — live-filter routes, toggle between file/method grouping
- Request builder — path params, query params, custom headers, bearer token field, JSON body editor
- Body pre-fill —
req.bodyfields auto-detected from handler source code and pre-populated - Response viewer — syntax-highlighted JSON, raw text, response headers, status, timing, size
- Variables —
{{VAR_NAME}}placeholders in any field;BASE_URLseeded automatically - Rescan — re-discover routes without restarting anything
- State persistence — inputs saved per-route in localStorage
Options
// auto-relay.config.js
module.exports = {
rootDir: './', // directory to scan (default: process.cwd())
port: 4000, // relay server port (default: 4000)
baseUrl: 'http://localhost:3000', // your app's base URL
exclude: ['tests/**', 'mocks/**'], // extra glob patterns to skip
title: 'Auto Relay', // browser tab title
};| Option | Type | Default | Description |
|-----------|------------|-------------------------|------------------------------------------------|
| rootDir | string | process.cwd() | Root directory to scan for Express routes |
| port | number | 4000 | Port the relay explorer runs on |
| baseUrl | string | http://localhost:3000 | Base URL of your running Express app |
| exclude | string[] | [] | Extra glob patterns to skip during scanning |
| title | string | Auto Relay | Title shown in the browser tab and header |
CLI flags
npx auto-relay start --port=5000 # override port from CLIHow it differs from auto-detect-route
| | auto-detect-route | auto-relay |
|---|---|---|
| Setup | Add middleware to your Express app | Install package + run CLI |
| Changes to your app | Yes — app.use('/explorer', ...) | None |
| Runs | Inside your app process | Separate process, separate port |
| Config | Options passed to middleware | auto-relay.config.js file |
Use auto-relay when you don't want to touch your app code at all.
How it works
auto-relay start reads your config, then:
- Scans your source files using AST parsing (
@typescript-eslint/typescript-estree) — same engine as theauto-detect-routepackage. - Starts a standalone Express server on the configured port.
- Proxies requests from the browser UI to your running app — no CORS issues.
The scan uses a 3-pass algorithm: parse all files → find entry points → DFS across require()/import chains to resolve full route paths including nested router prefixes.
Security
- Sensitive files (
.env,.key,.pem, credentials) are never read by the scanner - Only
http:andhttps:protocols are allowed in the proxy - Response bodies are capped at 10 MB
- Keep the relay server on localhost — do not expose it publicly
License
MIT
