-
-
Save ajcrites/6527261 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function required(params) { | |
return function (req, res, cb) { | |
params.every(function (elem) { return req.body.hasOwnProperty(elem); }) | |
&& cb() | |
|| res.send(400); | |
}; | |
}; | |
/** | |
* Sample route | |
*/ | |
app.get("/route", required(["user_string"]), function(req, res) { | |
var respObj = {} | |
user_string = req.body.user_string; | |
res.writeHead(200, {'content-type': 'application/json'}); | |
res.end(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment