mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-24 05:39:35 +02:00
Added login route and token signing
This commit is contained in:
parent
ea57dbf750
commit
5805c708d2
8 changed files with 153 additions and 1 deletions
13
middleware/requireBody.js
Normal file
13
middleware/requireBody.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
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;
|
Loading…
Add table
Add a link
Reference in a new issue