Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/VladimirMikulic/route-list
Beautifully shows Express/Koa/Hapi/Fastify routes in CLI.
https://github.com/VladimirMikulic/route-list
command-line-tool expressjs fastify hapi koa routes
Last synced: 3 months ago
JSON representation
Beautifully shows Express/Koa/Hapi/Fastify routes in CLI.
- Host: GitHub
- URL: https://github.com/VladimirMikulic/route-list
- Owner: VladimirMikulic
- License: mit
- Created: 2022-10-16T18:23:08.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-24T16:28:37.000Z (3 months ago)
- Last Synced: 2024-10-25T15:21:09.446Z (3 months ago)
- Topics: command-line-tool, expressjs, fastify, hapi, koa, routes
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/route-list
- Size: 620 KB
- Stars: 321
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# route-list
![Version](https://img.shields.io/npm/v/route-list)
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
[![CI](https://github.com/VladimirMikulic/route-list/actions/workflows/ci.yml/badge.svg)](https://github.com/VladimirMikulic/route-list/actions)
[![Twitter: VladoDev](https://img.shields.io/twitter/follow/VladoDev.svg?style=social)](https://twitter.com/VladoDev)> β¨ Beautifully shows Express/Koa/Hapi/Fastify routes in CLI.
![route-list CLI example](./screenshots/showcase.png)
## π¦ Installation
```sh
# Installs the package so it's globally accessible in terminal
npm i route-list -g
```## π Configuration
Before you can use `route-list` on your project, we first need to make sure it's configured properly.
In order for `route-list` to work, we need to export server "app".
The example below is for Express but it also applies to Koa (with @koa/router)/Hapi/Fastify.**app.js** / **app.ts**
```js
const app = express();app.get('/', (req, res) => res.sendStatus(200));
app.get('/products', (req, res) => res.sendStatus(200));
app.get('/products/:id', (req, res) => res.sendStatus(200));// CJS
// Option 1: module.exports = app;
// Option 2: module.exports = { app, yourOtherExports... };
// Option 3: module.exports = functionThatReturnsApp;// ESM
// Option 1: export default app;
// Option 2: export default { app, yourOtherExports... };
// Option 3: export default functionThatReturnsApp;
```> NOTE: In case you use [SocketIO with Express](https://socket.io/get-started/chat#the-web-framework), make sure to **export Express app**, not `http.createServer` server instance.
## βοΈ Usage
### Options
- `-g, --group` - Display routes in groups separated with new line
- `-m, --methods ` - Include routes registered for HTTP method(s)
- `-i, --include-paths ` - Include routes starting with path(s)
- `-e, --exclude-paths ` - Exclude routes starting with path(s)### Examples
```sh
route-list server/app.js
``````sh
route-list --group server/app.js
``````sh
route-list --methods GET,POST server/app.js
```> NOTE: In case an app is part of NX monorepo, make sure to build it first.
## π» Programmatic Usage
```js
import RouteList from 'route-list';// Example result { "/": ["GET"], "/users": ["GET", "POST"] }
const routesMap = RouteList.getRoutes(app, 'express');// Print routes to console
RouteList.printRoutes(routesMap);
```## π¨ Author
**Vladimir Mikulic**
- Twitter: [@VladoDev](https://twitter.com/VladoDev)
- Github: [@VladimirMikulic](https://github.com/VladimirMikulic)
- LinkedIn: [@vladimirmikulic](https://www.linkedin.com/in/vladimir-mikulic/)## π€ Contributing
Contributions, issues and feature requests are welcome!
## π» Credits
The project was inspired by new `route:list` command in Laravel 9.
New [`route:list`](https://github.com/laravel/framework/pull/40269) itself was
inspired by [`pretty-routes`](https://github.com/Wulfheart/pretty-routes) project.
Big thanks to [Ξlex Wulf](https://twitter.com/alexfwulf) for building
`pretty-routes` and Laravel community for recognizing the usefulness of the project.## βοΈ License
This project is licensed under [MIT](https://opensource.org/licenses/MIT) license.
## π¨βπ Show your support
Give a βοΈ if this project helped you!