@swyftx/express-unless-and
Advanced tools
Comparing version 1.0.0 to 1.0.2
{ | ||
"name": "@swyftx/express-unless-and", | ||
"description": "Conditionally add a middleware to express with some common patterns.", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"license": "MIT", | ||
@@ -42,3 +42,6 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/Swyftx/express-unless-and#readme" | ||
"homepage": "https://github.com/Swyftx/express-unless-and#readme", | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
@@ -1,6 +0,6 @@ | ||
Conditionally skip a middleware when a condition is met. | ||
Conditionally skip a middleware when a condition is met. Conditions are ANDed instead of ORed like [express-unless](https://www.npmjs.com/package/express-unless). | ||
## Install | ||
npm i express-unless --save | ||
npm i express-unless-and --save | ||
@@ -12,9 +12,8 @@ ## Usage | ||
```javascript | ||
var unless = require('express-unless'); | ||
const unless = require('express-unless-and') | ||
const static = express.static(__dirname + '/public') | ||
static.unless = unless | ||
var static = express.static(__dirname + '/public'); | ||
static.unless = unless; | ||
app.use(static.unless({ method: 'OPTIONS' })); | ||
app.use(static.unless({ method: 'OPTIONS' })) | ||
``` | ||
@@ -26,10 +25,10 @@ | ||
module.exports = function (middlewareOptions) { | ||
var mymid = function (req, res, next) { | ||
let mymid = function (req, res, next) { | ||
}; | ||
} | ||
mymid.unless = require('express-unless'); | ||
mymid.unless = require('express-unless-and') | ||
return mymid; | ||
}; | ||
return mymid | ||
} | ||
``` | ||
@@ -59,9 +58,9 @@ | ||
Avoid a fstat for request to routes doesnt end with a given extension. | ||
Avoid an fstat for request to routes that don't end with a given extension. | ||
```javascript | ||
app.use(static.unless(function (req) { | ||
var ext = url.parse(req.originalUrl).pathname.substr(-4); | ||
return !~['.jpg', '.html', '.css', '.js'].indexOf(ext); | ||
})); | ||
let ext = url.parse(req.originalUrl).pathname.substr(-4) | ||
return !~['.jpg', '.html', '.css', '.js'].indexOf(ext) | ||
})) | ||
``` | ||
@@ -68,0 +67,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118396
68