Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    express-resetterpublic

    express-resetter

    This is a simple utility module to reset an Express instance to a previous state after registering middleware. This is very helpful for hot-reloading changes to routes during development (without requiring the restart of the entire application).

    Installation

    npm install express-resetter --save
    

    Usage

    var expressResetter = require('express-resetter');
    //...
    app.use(beforeMiddlewareA);
    app.use(beforeMiddlewareB);
    expressResetter.resetRoutes(app);
    app.use(afterMiddlewareA);
    app.use(afterMiddlewareA);

    The first time expressResetter.resetRoutes(app) is called it simply stores the current state of the Express app at the time it is invoked. The second time expressResetter.resetRoutes(app) is called, the previous state is restored. In the above example, right after the second time resetRoutes is called, the only middleware that will be registered is beforeMiddlewareA and beforeMiddlewareB.

    However, the only caveat is that all the registered routes are always completely reset after the subsequent calls to resetRoutes.

    install

    npm i express-resetter

    Downloadsweekly downloads

    6

    version

    1.1.0

    license

    BSD

    repository

    githubgithub

    last publish

    collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar