Detalhes do pacote

express-list-endpoints

AlbertoFdzM430.2kMIT7.1.1

A express package to list all registered endpoints and its verbs

endpoint, endpoints, express, list

readme (leia-me)

Express List Endpoints

[!IMPORTANT] This package only works for express 4.* versions. It's not compatible with express 5 yet.

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.

changelog (log de mudanças)

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v7.1.1 - 2024-11-20

Fixed

  • Add compatibility with express 4.20 and above.

v7.1.0 - 2024-04-07

Added

  • Add logic for apps and routers with no routes to return an empty array.

Dev

  • Add TypeScript configuration and transpilation scripts.
  • Add types.

v7.0.0 - 2024-04-06

Added

  • Add support for NodeJS v18 and v20.
  • Add support for route param regexps.

Deprecated

  • BREAKING CHANGE Drop support for NodeJS v12, v14 and v16.

v6.0.0 - 2021-07-29

Deprecated

  • BREAKING CHANGE Drop support for NodeJS v10

Fixed

  • Fixed a problem when parsing the property middlewares for each endpoint being allocated in middleware property instead

Dev

  • Added CI using GitHub Actions
  • Update dev dependencies
  • Removed TravisCI from the project
  • Refactor code to use new JS methods and improve readability

v5.0.0 - 2020-07-12

Added

  • mounted_app is being parsed
  • Request handlers mounted on multiple routes by passing an array are being parsed
  • If a route path contains an unparseable regexp it is used to compose the path

Changed

  • Added middlewares property in reports representing mounted middlewares by their name

Fixed

  • Avoid method duplicity in the same path

Deprecated

  • BREAKING Drop support for NodeJS v6 and v8
  • Drop support for yarn.lock file

Dev

  • Update dev dependencies
  • Improve tests structure

v4.0.1 - 2019-05-06

Fixed

  • Add logic to avoid duplicate paths #40

v4.0.0 - 2018-10-14

Changed

  • Replace build script that versions the changelog for changelog-version package #36
  • Update devDependencies
  • Improve code readability

BREAKING CHANGES

  • Drop support for NodeJS v4

v3.0.1 - 2017-10-25

🐛 Fixed

  • Fix params on Base route with multi-level routing

Changed

  • Update devDependencies

v3.0.0 - 2016-12-18

BREAKING CHANGES

  • Removed support for Node v0.12

🐛 Fixed

  • Now the params set in middle of a pattern get parsed #17

Dev

  • Move main file to src folder
  • Add lint script
  • Ignore editorconfig file for npm relases
  • Changed codestyle to standard #18
  • Implemented Yarn on the project #19

Changed

  • Add more test cases.

v2.0.3 - 2016-11-05

🐛 Fixed

  • Super multi-level baseRoutes handled #10

v2.0.1 - 2016-11-05

Changed

  • Update dependencies
  • Fix typos in README file #6
  • Improve README file #7

Fixed 🐛

  • Multi-level basePaths are now parsed correctly #10

2.0.0 - 2016-04-24

  • Implemented Travis CI on the project. #3
  • Implemented CodeCov on the project. #4
  • Now the passed arguments are the app or router instance. #5

1.1.1 - 2016-04-21

  • Updated dependencies
  • Now express is a development dependency
  • Improved tests

1.1.0 - 2016-04-20

  • Improved regexp to parse express router. #1
  • Added editorconfig file.

1.0.1 - 2016-01-18

  • Update package version

1.0.0 - 2016-01-18

  • Add changelog file
  • Improve README file

0.0.0 - 2016-01-18

  • Change npm test script to run mocha
  • Now getEndpoints retrieve array of object with paths and methods
  • getRouteMethods now return an array of methods
  • Tests
  • First commit