express-list-routes

List routes for Express

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
express-list-routes
3501.2.13 months ago9 years agoMinified + gzip package size for express-list-routes in KB

Readme

express-list-routes
List all routes used in Express3,4,5
!NPM Versionnpm-imagenpm-url !NPM Downloadsdownloads-imagedownloads-url
Example App
const express = require('express');
const expressListRoutes = require('express-list-routes');

const app = express();

app.get('/health', fn)

app.use('/admin', router);
router.route('/user')
  .post(fn)
  .get(fn)
  .put(fn);
``` 
**List all Routes with prefix**
```js
expressListRoutes(app, { prefix: '/api/v1' });
// Logs out the following:
// GET    /api/v1/health
// POST   /api/v1/admin/user
// GET    /api/v1/admin/user
// PUT    /api/v1/admin/user
Or only log out nested router routes
expressListRoutes(router);
// Logs out the following:
// POST   /admin/user
// GET    /admin/user
// PUT    /admin/user

Installation

npm install express-list-routes

Options

You can pass a second argument to set some options
{
  prefix: '', // A prefix for router Path
  spacer: 7   // Spacer between router Method and Path
  logger: console.info // A custom logger function
  color: true // If the console log should color the method name
}

FAQ

Errors with importing this library You may need to enable esModuleInterop in your tsconfig.json to support default exports.