Created
August 3, 2016 16:58
-
-
Save jeremyjs/7fa588c21709638a80367be94a882eee 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
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