Comments (9)
+1
from express-unless.
+1
from express-unless.
+1, just ran into this today. For the time being I will write a custom function to achieve the desired logic, but it seems like a simple addition of another attribute.
from express-unless.
+1
from express-unless.
+1
from express-unless.
The way I accomplished this with a custom unless function:
app.use(middleware().unless(function(req) {
return (
req.originalUrl === '/endpoint1' && req.method === 'GET' ||
req.originalUrl === '/endpoint2' && req.method === 'POST'
);
}));
Hope it helps.
from express-unless.
@goncaloneves Thanks for the code. It works, but it would be nice if it was baked in.
from express-unless.
@chuckconway @goncaloneves feature added in v0.3
from express-unless.
I'm using unless with express-jwt to whitelist some endpoints from having to have token, but looks like it does not respect the http method I provide
app.use(
jwt({
secret: process.env.JWT_SECRET
}).unless({
path: [
//...
{ url: 'estimate/category', method: 'GET' },
//...
]
})
as I understand, it should whitelist 'estimate/category' just for GET method, in other words, I have to provide token if it is POST or PATCH and don't have to provide token if it's GET
but it is whitelisting it for all methods.
I think the problem is here:
Line 42 in 04b49c4
Shouldn't it be a && here?
This code says here if skip exists, methods are not important
Environment
I'm using:
"express": "4.17.1",
"express-jwt": "5.3.3",
"express-unless":"0.3.1"
from express-unless.
Related Issues (20)
- use module `path-to-regexp` for path HOT 2
- Unintentionally Bypassing Middleware with Case-Sensitive Negative Regex
- 404 route? HOT 2
- Unless is not working HOT 9
- Unless params HOT 1
- chaining unless HOT 1
- Add license to package.json HOT 1
- Support GraphQL queries
- More examples HOT 1
- not able to get 'unless' working HOT 1
- Can't get it working
- Not working HOT 4
- Is the library no longer supported? HOT 1
- Allow parent path but do-not allow subpath to have access HOT 1
- Exclude a route with uuid v4 HOT 3
- "UnhandledPromiseRejectionWarning" if middleware throws exception (Version 1.0.0) HOT 1
- Possible "custom" option missing ? HOT 5
- Changelog HOT 9
- Recent update may have missing type definition? v2.1.3 HOT 9
- Migrating to v2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-unless.