route-map-cli
v0.1.1
Published
Map application routes from common JavaScript and TypeScript web projects.
Downloads
13
Maintainers
Readme
route-map-cli
Map application routes from common JavaScript and TypeScript web projects.
route-map scans a project and prints the routes it can infer from file-system routers and server router calls. It is intentionally small: useful in a terminal, easy to add to CI, and safe to run before a deploy.
Install
npm install --save-dev route-map-cliUsage
npx route-map-cli
npx route-map-cli --tree
npx route-map-cli --json
npx route-map-cli ./apps/webExample output:
GET / next-app app/page.tsx
GET /blog/:slug next-app app/blog/[slug]/page.tsx
POST /api/posts express-like src/server.ts
API /api/users next-pages pages/api/users.tsSupported Route Shapes
- Next.js App Router:
app/**/page.tsx,app/**/route.ts - Next.js Pages Router:
pages/**/*.tsx, includingpages/api - Remix flat routes:
app/routes/**/*.tsx - React Router route modules:
routes/**/*.tsx,src/routes/**/*.tsx - Express-like calls:
app.get("/path"),router.post("/path"),fastify.route({ method, url })
Dynamic file segments are normalized:
app/users/[id]/page.tsx -> /users/:id
app/docs/[...slug]/page.tsx -> /docs/*slug
app/(admin)/settings/page.tsx -> /settingsAPI
import { createRouteMap, formatRouteMap } from "route-map-cli";
const routes = await createRouteMap({ cwd: "./apps/web" });
console.log(formatRouteMap(routes));CLI
After installing the package, use the route-map binary:
route-map [path]
route-map --cwd ./app --json
route-map --treeOptions:
--cwd <path>: project directory to scan--json: print route entries as JSON--tree: print one line per route path with grouped methods--no-api: exclude Next.jspages/apiroutes
License
MIT
