node-enterprise-starter
Version:
<h1 align="center">Node Enterprise Starter</h1>
17 lines (13 loc) • 418 B
text/typescript
import { NextFunction, Request, Response } from 'express';
import { AnyZodObject } from 'zod';
import catchAsync from '../utils/catchAsync';
const validateRequest = (schema: AnyZodObject) => {
return catchAsync(async (req: Request, res: Response, next: NextFunction) => {
await schema.parseAsync({
body: req.body,
cookies: req.cookies,
});
next();
});
};
export default validateRequest;