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
I have a case where it's taking me a little while to do something in the .before() request handler. Express.js's method for handling this kind of behavior is to either send a response or to call next(); I realize this might be a major feature request, but .before() is misleading because it doesn't actually wait to run any routes. It just does stuff sequentially, without any pause.
My example:
this.before(function (req) {
// send a request to the server to see if user is authenticated
// if user is authenticated, allow the route to continue (next())
// if user is not authenticated, reroute them
});
The problem is, since it takes a split second to ping the server for this information (in my case, there's a reason to not just use local storage), IT ACTUALLY RENDERS THE ADMIN PAGE before rerouting. It's only a split second, but this is unfortunate. :(
Basically, 1) is there a next() concept in Davis.js, and 2) if not, why, and 3) can there be something like next() added?
The text was updated successfully, but these errors were encountered:
Davis actually uses a very similar approach to express with route middleware. These are currently only at an individual route level but should acheive exactly what you are looking for.
var isAdmin = function (req, next) {
checkForAdminRole(function (success) {
if (success) {
next(req)
} else {
// do whatever
}
})
}
this.get('/admin', isAdmin, function (req) {
// admin related stuff in here
})
This is actually the direction I would like to get before filters to go, but this is a way of yet.
I have a case where it's taking me a little while to do something in the .before() request handler. Express.js's method for handling this kind of behavior is to either send a response or to call next(); I realize this might be a major feature request, but .before() is misleading because it doesn't actually wait to run any routes. It just does stuff sequentially, without any pause.
My example:
The problem is, since it takes a split second to ping the server for this information (in my case, there's a reason to not just use local storage), IT ACTUALLY RENDERS THE ADMIN PAGE before rerouting. It's only a split second, but this is unfortunate. :(
Basically, 1) is there a next() concept in Davis.js, and 2) if not, why, and 3) can there be something like next() added?
The text was updated successfully, but these errors were encountered: