Is the anyway to add some middleware to specific actions? because as far as I know addPreProcessor adds the middleware to all the actions? lets say you don't want to have authentication or some other checks on some actions, is there any solution?
I have a short term solution but it would be nice if you could assign your specific middlewares when you're defining your action(like giving an array of middleware names that need to be run, in order)
My current solution is keeping an array of all the actions that I need to apply the middleware to them and then check it against the connection.aciton, but then still every single request goes through all the middlewares and then it gets passed around which it doesn't sound efficient to me!
exports.middlewares = function(api, next){
var myImportantMiddleware = function(connection, actionTemplate, next) {
var actionsToBeChecked = ['deposit'];
var action = connection.action;
if(actionsToBeChecked.indexOf(action) > -1) {
/* middleware logic
next(connection, true); */
} else {
next(connection, true);
}
}
api.actions.addPreProcessor(myImportantMiddleware);
next();
}
Thanks in advance !