Nonsense Parser Microframework

    @kamalyb/express-list-routes
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.12 • Public • Published

    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();
    
    const router = express.Router();
    
    router.route("/user").post(fn).get(fn).put(fn);
    
    expressListRoutes(router);
    
    app.get("/health", fn);
    
    app.use("/admin", router);

    List all Routes with prefix

    Note: This does not work as with express-list-routes. It must take an instance of express.Router

    expressListRoutes(app);

    This works

    expressListRoutes(router, { prefix: "/admin" });
    // Logs out the following:
    // POST   /admin/user
    // GET    /admin/user
    // PUT    /admin/user

    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: '', // A prefix for router Path
        spacer: 7   // Spacer between router Method and Path
      }

    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' });

    Install

    npm i @kamalyb/express-list-routes

    DownloadsWeekly Downloads

    1

    Version

    1.1.12

    License

    ISC

    Unpacked Size

    21.7 kB

    Total Files

    8

    Last publish

    Collaborators

    • kamalyusuf