You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is even deeper than i've described in the caption. Lets say i have this code:
const get = Picker.filter(function(req, res) {
return req.method == 'GET';
});
const post = Picker.filter(function(req, res) {
return req.method == 'POST';
});
// Hello there, you have no documentation provided about custom middleware, but it's ok, i can use google
const someMiddleware = (req, res, next) => {
console.log('see this on any route, lol');
next();
}
// i would use the middleware only for POST requests, so i suppose i should write this way:
post.middleware(someMiddleware);
// no, u didn't get it, i even expect the middleware is gonna be run only for this route: /api/items/
// just notice: why did u splited out the params from the req object? The Express does not, so it makes some mess, when i want to assign some URL/HEADER/BODY encoded parameters to some local variable, but the word "params" is already busy
post.route('/api/items/', callback);
// and lets say i want to provide some SEO markup for google/tweeter/blablaElse bots with this one:
const seo = Picker.filter(function(req, res) {
return req.method == 'GET';
});
seo.get('/', seoCallback);
Ok, what do we have? Unexpected behavior for a normal mind flow:
'see this on any route, lol' - u will see this on every request, does not metter, did u come to '/', or '/api/items' with POST header. Filter also does not make effect on a decision to launch or not to launch a middleware. So all code above makes absolutly NO sense! You can not validate some header encoded parameter, with redirect on fail or next() on success, in middleware for specific route of a specific filter.
The text was updated successfully, but these errors were encountered:
Don't get me wrong and I'm sorry if I'm too hard. But it peaces me off, when I'm understanding, that your code applies the multer(npm middleware) for EVERY ROUTE in the app!!! Even if it should be handled on a client side...
The problem is even deeper than i've described in the caption. Lets say i have this code:
Ok, what do we have? Unexpected behavior for a normal mind flow:
'see this on any route, lol' - u will see this on every request, does not metter, did u come to '/', or '/api/items' with POST header. Filter also does not make effect on a decision to launch or not to launch a middleware. So all code above makes absolutly NO sense! You can not validate some header encoded parameter, with redirect on fail or next() on success, in middleware for specific route of a specific filter.
The text was updated successfully, but these errors were encountered: