express-list-routes
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

express-list-routes

List all routes used in Express[3,4,5]

NPM Version NPM Downloads

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

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 or a boolean (true for default logger, false for no logging)
    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.

Package Sidebar

Install

npm i express-list-routes

Weekly Downloads

9,078

Version

1.2.2

License

ISC

Unpacked Size

16.1 kB

Total Files

10

Last publish

Collaborators

  • labithiotis