import { Controller } from '../../src/decorators/controller' ; import * as METHODS from '../../src/decorators/requestMethods' ; import * as HOOKS from '../../src/decorators/hooks' ; import type { RouteShorthandOptions } from 'fastify' ; export const controllerFactory = ( controllerRoute , methods = [ ] , hooks = [ ] ) => { @ Controller ( controllerRoute ) class TestController { } methods . forEach ( ( methodConfig , index ) => { TestController . prototype [ `${ methodConfig . method }_${ index }` ] = methodConfig . handler ; METHODS [ methodConfig . method ] ( methodConfig . route , methodConfig . options as any || { } ) ( TestController . prototype , `${ methodConfig . method }_${ index }` ) ; } ) ; hooks . forEach ( ( hookConfig , index ) => { TestController . prototype [ `${ hookConfig . hook }_${ index }` ] = hookConfig . handler ; HOOKS [ hookConfig . hook ] ( TestController . prototype , `${ hookConfig . hook }_${ index }` ) ; } ) ; return TestController ; } ;