
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
collect-express-routes
Advanced tools
Collect all API routes in Express Application / Router
This package helps to make "sitemap" of the APIs.
express() application and express.Router()app.route)import express, { Request, Response } from 'express'
import {
groupRoutesByPath,
getSpyRoutes,
spyRoutes,
} from 'collect-express-routes'
let app = express()
spyRoutes(app)
app.use(express.json())
// direct routing is supported
app.get('/users', echo)
app.post('/users', echo)
app.get('/users/:id', echo)
app.patch('/users/:id', echo)
app.delete('/users/:id', echo)
// using router is also supported
let memoRouter = express.Router()
memoRouter.post('/', echo)
memoRouter.get('/:id', echo)
memoRouter.patch('/:id', echo)
memoRouter.delete('/:id', echo)
app.use('/memo', memoRouter)
// chainable route handlers are also supported
app
.route('/book')
.get(echo) // alias for app.get('/book', echo)
.post(echo) // alias for app.post('/book', echo)
console.log(getSpyRoutes(app))
/* output:
[
{ method: 'get', path: '/users' },
{ method: 'post', path: '/users' },
{ method: 'get', path: '/users/:id' },
{ method: 'patch', path: '/users/:id' },
{ method: 'delete', path: '/users/:id' },
{ method: 'post', path: '/memo' },
{ method: 'get', path: '/memo/:id' },
{ method: 'patch', path: '/memo/:id' },
{ method: 'delete', path: '/memo/:id' }
{ method: 'get', path: '/book' },
{ method: 'post', path: '/book' },
]
*/
console.log(groupRoutesByPath(getSpyRoutes(app)))
/* output:
{
'/users': [ 'get', 'post' ],
'/users/:id': [ 'get', 'patch', 'delete' ],
'/memo': [ 'post' ],
'/memo/:id': [ 'get', 'patch', 'delete' ],
'/book': [ 'get', 'post' ]
}
*/
function echo(req: Request, res: Response) {
res.json({ method: req.method, path: req.path })
}
Details see spy.spec.ts
This project is licensed with BSD-2-Clause
This is free, libre, and open-source software. It comes down to four essential freedoms [ref]:
FAQs
Collect all API routes in Express Application / Router
We found that collect-express-routes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.