Added: api init project

This commit is contained in:
2023-12-31 00:21:26 +01:00
parent dad526fdee
commit cf20935e01
34 changed files with 8041 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
import { Request, Response, NextFunction } from 'express'
import { validationResult } from 'express-validator'
import { Err } from '../services/globalService'
class Middleware {
handleValidationError(req: Request, res: Response, next: NextFunction) {
const error = validationResult(req)
if (!error.isEmpty()) {
new Err(400, error)
return res.status(400).json(new Err(400, 'validation error', error.array()[0]))
}
next()
}
}
export default new Middleware()