express-list-routes
A typescript'd fork of express-list-routes solely as a result of personal need
Example App
import express, { Express } from "express";
import expressListRoutes from "@kamalyb/express-list-routes";
const app: Express = express();
app.get("/health", fn);
app.use("/admin", router);
router.route("/user").post(fn).get(fn).put(fn);
List all Routes with prefix
expressListRoutes(app, { prefix: "/api/v1" });
Or only log out nested router routes
expressListRoutes(router);
Installation
npm install @kamalyb/express-list-routes
yarn add @kamalyb/express-list-routes
Options
You can pass a second argument to set some options
{
prefix: '',
spacer: 7
}
Migrations
0.1 -> 1.0
The order of the params have changed, and dropped support for freeform text.
BEFORE 0.1<
expressListRoutes({ prefix: '/api/v1' }, 'API:', router);
AFTER 1.0+
expressListRoutes(router, { prefix: '/api/v1' });