Update bcryptjs to version 3.0.3 and add smoke-tracker router to the server configuration.
This commit is contained in:
21
server/routers/smoke-tracker/utils.js
Normal file
21
server/routers/smoke-tracker/utils.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const requiredValidate =
|
||||
(...fields) =>
|
||||
(req, res, next) => {
|
||||
const errors = []
|
||||
|
||||
fields.forEach((field) => {
|
||||
if (!req.body[field]) {
|
||||
errors.push(field)
|
||||
}
|
||||
})
|
||||
|
||||
if (errors.length) {
|
||||
throw new Error(`Не все поля заполнены: ${errors.join(', ')}`)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.requiredValidate = requiredValidate
|
||||
|
||||
|
||||
Reference in New Issue
Block a user