Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 5 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 (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2024-06-16T09:56:41.000Z (5 months ago)
- Last Synced: 2024-11-02T16:39:08.196Z (10 days ago)
- Topics: endpoints, express, expressjs, nodejs, routes
- Language: JavaScript
- Homepage:
- Size: 485 KB
- Stars: 166
- Watchers: 4
- Forks: 30
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Express List Endpoints
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/AlbertoFdzM/express-list-endpoints/ci.yml?branch=main&logo=github)](https://github.com/AlbertoFdzM/express-list-endpoints/actions/workflows/ci.yml?query=branch%3Amain) [![Codecov Coverage Report](https://img.shields.io/codecov/c/github/AlbertoFdzM/express-list-endpoints/main)](https://codecov.io/github/AlbertoFdzM/express-list-endpoints?branch=main) [![Code Climate Maintainability Report](https://img.shields.io/codeclimate/maintainability/AlbertoFdzM/express-list-endpoints)](https://codeclimate.com/github/AlbertoFdzM/express-list-endpoints/maintainability) [![NPM Downloads](https://img.shields.io/npm/dm/express-list-endpoints)
](https://www.npmjs.com/package/express-list-endpoints) [![NPM License](https://img.shields.io/npm/l/express-list-endpoints)](https://www.npmjs.com/package/express-list-endpoints)[![NPM Package Page](https://img.shields.io/badge/express--list--endpoints-gray?label=npm&labelColor=c21104)](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).