Added: tests, signin api, not working docker
This commit is contained in:
15
api/src/middlewares/validateRequest.ts
Normal file
15
api/src/middlewares/validateRequest.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
import { object, AnySchema } from 'yup';
|
||||
import { Log } from 'nork';
|
||||
|
||||
const validate = (schema: AnySchema) => async (req: Request, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
await schema.validate(req.body);
|
||||
|
||||
next();
|
||||
} catch (err: any) {
|
||||
return res.status(400).json(Log.error(400, 'validation error', err));
|
||||
}
|
||||
};
|
||||
|
||||
export default validate;
|
Reference in New Issue
Block a user