import { NextFunction , Request , Response } from 'express' ; import { validationResult } from 'express-validator' ; export const controllerContainer = ( f ) => { return async ( req , res , next ) => { const errors = validationResult ( req ) ; if ( ! errors . isEmpty ( ) ) { return next ( errors . array ( ) ) ; } try { await f ( req , res ) ; } catch ( error ) { next ( error ) ; } } ; } ;