https://github.com/albertofdzm/express-list-endpoints
A express package to list all registered endpoints and its verbs
https://github.com/albertofdzm/express-list-endpoints
endpoints express expressjs nodejs routes
Last synced: 20 days ago
JSON representation
A express package to list all registered endpoints and its verbs
- Host: GitHub
- URL: https://github.com/albertofdzm/express-list-endpoints
- Owner: AlbertoFdzM
- License: mit
- Created: 2016-01-18T16:40:57.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2025-02-18T00:37:12.000Z (4 months ago)
- Last Synced: 2025-04-02T05:47:03.815Z (2 months ago)
- Topics: endpoints, express, expressjs, nodejs, routes
- Language: JavaScript
- Homepage:
- Size: 505 KB
- Stars: 173
- Watchers: 3
- Forks: 31
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Express List Endpoints
> [!IMPORTANT]
> This package only works for express 4.\* versions. It's not compatible with express 5 yet.[](https://github.com/AlbertoFdzM/express-list-endpoints/actions/workflows/ci.yml?query=branch%3Amain) [](https://codecov.io/github/AlbertoFdzM/express-list-endpoints?branch=main) [](https://codeclimate.com/github/AlbertoFdzM/express-list-endpoints/maintainability) [
](https://www.npmjs.com/package/express-list-endpoints) [](https://www.npmjs.com/package/express-list-endpoints)[](https://www.npmjs.com/package/express-list-endpoints)
Express endpoint parser to retrieve a list of the passed router with the set verbs.
## Examples of use
```javascript
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' ]
}
]
*/
``````typescript
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:
```shell
npm test
```## License
Express List Endpoints is [MIT licensed](./LICENSE).