Skip to content

Instantly share code, notes, and snippets.

@deleteman
Created May 31, 2014 15:44
Show Gist options
  • Save deleteman/51bc77ae865f38fa57a5 to your computer and use it in GitHub Desktop.
Save deleteman/51bc77ae865f38fa57a5 to your computer and use it in GitHub Desktop.
Url specific pre processors on Vatican.js
//Current solution
var Vatican = require("vatican");
var app = new Vatican();
app.preprocessor(function(req, res, next) {
if(req.url.indexOf("/auth/unregister") != -1) {
//do the checks
if(error) next(error)
}
next();
});
//Possible solutions for 1.3 based on your question:
//For this solution, an array of path expressions can be passed, so the preprocessor will only be triggered when the current path matches one of the given posibilities
app.preprocessor(jwtCallback, ['/auth/unregister']);
//Another option is to have the @endpoint annotation have another option, like this:
//.. in your auth handler
@endpoint (url: /auth/unregister method: delete preprocessor: jwtCallback)
Auth.prototype.unregister = //....
@deleteman
Copy link
Author

I like that idea!!! Thank you for the feedback!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment