import Joi from 'joi' ; import { Socket } from 'socket.io' ; import { logger } from "../../../../logger" ; export abstract class BaseWSController < T = { } > { private reqSchema : Joi . Schema < T > ; constructor ( req ) { this . reqSchema = req ; } protected abstract executeImpl ( socket , payload ) ; public async execute ( socket , req ) { req = req != null ? req : { } ; const schemaValidationRes = this . reqSchema . validate ( req ) ; if ( schemaValidationRes . error ) { return ; } const payload = schemaValidationRes . value as T ; try { await this . executeImpl ( socket , payload ) ; } catch ( err ) { logger . error ( { error : err } , `[BaseController]: Uncaught controller error` ) ; } } }