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": "*" for the latest version"maybe-middleware": "1.0.0" for the version 1.0.0
launch this command:
npm install maybe-middleware --save
var maybeMiddleware = ;// Import some other required modulesvar express = ;var app = ;var responsePoweredBy = ;var POWERED_BY = "@NIckNaso";// Some other configuration for the express app and session// predicate as booleanapp;// OR// predicate as functionapp;
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.