Socket
Socket
Sign inDemoInstall

express-list-routes

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    express-list-routes

List routes for Express


Version published
Weekly downloads
7K
decreased by-35.39%
Maintainers
1
Install size
15.5 kB
Created
Weekly downloads
 

Readme

Source

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
    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.

Keywords

FAQs

Last updated on 05 Mar 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc