First typescript iteration
This commit is contained in:
parent
d5f345ed4c
commit
65fcc3119c
113 changed files with 1961 additions and 1784 deletions
21
server/middlewares/validators/utils.ts
Normal file
21
server/middlewares/validators/utils.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { inspect } from 'util'
|
||||
|
||||
import { logger } from '../../helpers'
|
||||
|
||||
function checkErrors (req, res, next, statusCode?) {
|
||||
if (statusCode === undefined) statusCode = 400
|
||||
const errors = req.validationErrors()
|
||||
|
||||
if (errors) {
|
||||
logger.warn('Incorrect request parameters', { path: req.originalUrl, err: errors })
|
||||
return res.status(statusCode).send('There have been validation errors: ' + inspect(errors))
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
checkErrors
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue