diff --git a/src/Tools.js b/src/Tools.js new file mode 100644 index 0000000..253254c --- /dev/null +++ b/src/Tools.js @@ -0,0 +1,13 @@ +//check whether all given params exist in an object +//var success = .reqParamsGiven(["username", "password"], req.body); +exports.reqParamsGiven = function (keys, obj) { + if(typeof(obj) != "object" || obj.length < 1) return false; + for(k in keys) { + var key = keys[k]; + var value = obj[key]; + if(value == undefined) { + return false; + } + } + return true; +} \ No newline at end of file