Socket
Book a DemoInstallSign in
Socket

express-resetter

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-resetter

Utility module to reset an Express instance to a previous state after registering middleware

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
1
-83.33%
Maintainers
2
Weekly downloads
 
Created
Source

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.

Keywords

express

FAQs

Package last updated on 10 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts