Skip to content

Instantly share code, notes, and snippets.

@jeremyjs
Created August 3, 2016 16:58
Show Gist options
  • Save jeremyjs/7fa588c21709638a80367be94a882eee to your computer and use it in GitHub Desktop.
Save jeremyjs/7fa588c21709638a80367be94a882eee to your computer and use it in GitHub Desktop.
const _ = require('lodash');
const ensureReqHasAttr = (attr) => (
(req, res, next) => {
if (!_.has(req, attr)) {
return res.status(400).json({ error: `Request must contain ${attr}` });
}
next();
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment