Nihilism Philisophy Major

    express-capture-route
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.1 • Public • Published

    express-capture-route

    Capture route definitions, and reconstruct the original route.

    Wrap your Router and express() calls in capture, and it will annotate the objects such that it can recover the original path, through multiple layers of router and mounted sub-apps.

    Example

    See also examples/readme.ts: npm run example

    import * as express from 'express';
    import { capture, recoverFromHandler, recoverFromRequest } from 'express-capture-route';
    const router = capture(express.Router());
    router.get('/foo/:bar', foo);
     
    const app = express();
    app.use(someMiddleWare);
    capture(app).use('/api', router);
     
    recoverFromHandler(foo).path === ['/api', '/foo/:bar'];
     
    // or, with some `onFinished` middleware
    app.use((req, res, next) => {
      next();
      recoverFromRequest(req).path;
    });

    Keywords

    none

    Install

    npm i express-capture-route

    DownloadsWeekly Downloads

    9

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    10 kB

    Total Files

    9

    Last publish

    Collaborators

    • fauxfaux