Skip to content

Instantly share code, notes, and snippets.

@ajcrites
ajcrites / reqParams.js
Last active December 22, 2015 20:29 — forked from L1fescape/reqParams.js
function required(params) {
return function (req, res, cb) {
params.every(function (elem) { return req.body.hasOwnProperty(elem); })
&& cb()
|| res.send(400);
};
};
/**
* Sample route
var _ = require('lodash');
var test_data = [
{ id: 'a', order_by: 1 },
{ id: 'b', order_by: 2 },
{ id: 'c', order_by: 3 },
{ id: 'd', order_by: 4 },
{ id: 'e', order_by: 5 },
{ id: 'f', order_by: 6 },
{ id: 'g', order_by: 7 },
{ id: 'h', order_by: 8 },