Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-conditional-middleware

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-conditional-middleware - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

3

lib/conditional.js

@@ -0,1 +1,3 @@

var once = require('once');
/**

@@ -30,2 +32,3 @@ * Returns a middleware that can be used to conditionally execute another

return function (req, res, next) {
next = once(next);
if (condition === true || (typeof condition === 'function' && condition(req, res, next))) {

@@ -32,0 +35,0 @@ return middleware(req, res, next);

5

package.json
{
"name": "express-conditional-middleware",
"version": "1.0.2",
"version": "1.0.3",
"description": "Allow express middlewares to be overridden based on a condition.",

@@ -26,3 +26,6 @@ "repository": "https://github.com/elliotttf/express-conditional-middleware",

}
},
"dependencies": {
"once": "^1.3.2"
}
}

@@ -54,4 +54,29 @@ var conditional = require('../lib/conditional.js');

});
},
funcOnce: function (test) {
test.expect(2);
var count = 0;
var conditionFunc = function (req, res, next) {
next();
return true;
};
var middleware = conditional(
conditionFunc,
function (req, res, next) {
test.ok(true, 'Conditional executed.');
next();
test.done();
}
);
middleware({}, {}, function () {
count++;
test.equal(count, 1, 'Middleware only executed once.');
});
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc