express-list-endpoints

A express package to list all registered endpoints and its verbs

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
express-list-endpoints
15957.1.02 months ago8 years agoMinified + gzip package size for express-list-endpoints in KB

Readme

Express List Endpoints
GitHub Actions Workflow Status Codecov Coverage Report Code Climate Maintainability Report NPM Downloads NPM License
NPM Package Page
Express endpoint parser to retrieve a list of the passed router with the set verbs.

Examples of use

const express = require('express');
const expressListEndpoints = require('express-list-endpoints');

let app = express();

app.route('/')
  .all(function namedMiddleware(req, res) {
    // Handle request
  })
  .get(function(req, res) {
    // Handle request
  })
  .post(function(req, res) {
    // Handle request
  });

app.route('/about')
  .get(function(req, res) {
    // Handle request
  });

const endpoints = expressListEndpoints(app);

console.log(endpoints);

/* It omits 'all' handlers.
[
  {
    path: '/',
    methods: [ 'GET', 'POST' ],
    middlewares: [ 'namedMiddleware', 'anonymous', 'anonymous' ]
  },
  {
    path: '/about',
    methods: [ 'GET' ],
    middlewares: [ 'anonymous' ]
  }
]
*/

import express from 'express';
import expressListEndpoints from 'express-list-endpoints';

let app = express();

app.route('/')
  .all(function namedMiddleware(req, res) {
    // Handle request
  })
  .get(function(req, res) {
    // Handle request
  })
  .post(function(req, res) {
    // Handle request
  });

app.route('/about')
  .get(function(req, res) {
    // Handle request
  });

const endpoints = expressListEndpoints(app);

console.log(endpoints);

Arguments

app - Express app or router instance

Your router instance (router) or your app instance (app).
Note: Pay attention that before call this script the router or app must have the endpoints registered due to detect them.

Contributing to express-list-endpoints

Development

Running test:
npm test

License

Express List Endpoints is MIT licensed.