Nocturnal Prancing Mosquito
    Have ideas to improve npm?Join in the discussion! »

    express-list-routes

    1.1.3 • Public • Published

    express-list-routes

    List all routes used in Express.

    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
      }

    Migrations

    0.1 -> 1.0

    The order of the params have changed, and dropped support for freeform text.

    BEFORE 0.1<

    expressListRoutes({ prefix: '/api/v1' }, 'API:', router);

    AFTER 1.0+

    expressListRoutes(router, { prefix: '/api/v1' });

    Install

    npm i express-list-routes

    DownloadsWeekly Downloads

    1,690

    Version

    1.1.3

    License

    ISC

    Unpacked Size

    11.5 kB

    Total Files

    9

    Last publish

    Collaborators

    • avatar