mirror of
https://github.com/pawelmalak/flame.git
synced 2024-12-19 08:02:16 +03:00
14 lines
334 B
JavaScript
14 lines
334 B
JavaScript
const ErrorResponse = require('../utils/ErrorResponse');
|
|
|
|
const requireBody = (keys) => (req, res, next) => {
|
|
const missing = keys.filter((key) => !Object.keys(req.body).includes(key));
|
|
|
|
if (missing.length) {
|
|
return next(new ErrorResponse(`'${missing[0]}' is required`, 400));
|
|
}
|
|
|
|
next();
|
|
};
|
|
|
|
module.exports = requireBody;
|