Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
maybe-middleware
Advanced tools
Wrapper for enable or disable express or connect middleware based on condition.
This wrapper allow you to enable or disable an express or connect middleware. In some circumstances you would use a middleware only if some conditions are met.
If you want use maybe-middleware you have to install it. There are two methods for that: In your package.json add the following item:
"maybe-middleware": "version"
then digit
npm install
Example:
"maybe-middleware": "*" for the latest version
"maybe-middleware": "1.0.0" for the version 1.0.0
OR
launch this command:
npm install maybe-middleware --save
var maybeMiddleware = require('maybe-middleware');
// Import some other required modules
var express = require('express');
var app = express();
var responsePoweredBy = require('response-powered-by');
var POWERED_BY = "@NIckNaso";
// Some other configuration for the express app and session
// predicate as boolean
app.use(maybeMiddleware(responsePoweredBy(POWERED_BY), true));
// OR
// predicate as function
app.use(maybeMiddleware(
responsePoweredBy(POWERED_BY),
function () {
// some other instructions ...
return true;
}
));
The first parameter for maybe-middleware is an express middleware, while the second is a boolean value or a function that return a boolean value. If the parameter's type do not match with those required an error will be dispatched to the express error middleware. In pariticular the error will be an instance of MaybeMiddlewareError.
FAQs
Wrapper for enable or disable express or connect middleware based on condition.
The npm package maybe-middleware receives a total of 1 weekly downloads. As such, maybe-middleware popularity was classified as not popular.
We found that maybe-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.