@@ -16,8 +16,10 @@ type MiddlewareWithParamsTuple = [
1616export type TMiddleware = Array <
1717 typeof AbstractMiddleware | MiddlewareWithParamsTuple
1818> ;
19+ // biome-ignore lint/complexity/noBannedTypes: Route handlers are generic callable values from user controllers
20+ type RouteHandler = Function ;
1921type RouteObject = {
20- handler : Function ;
22+ handler : RouteHandler ;
2123 description ?: string ;
2224 middleware ?: TMiddleware | null ;
2325 request ?: ( unknown & { fields : unknown } ) | null ; // fields part of you magic
@@ -26,7 +28,7 @@ type RouteObject = {
2628
2729export type RouteParams = {
2830 [ method : string ] : {
29- [ path : string ] : RouteObject | Function ;
31+ [ path : string ] : RouteObject | RouteHandler ;
3032 } ;
3133} ;
3234
@@ -92,7 +94,7 @@ class AbstractController extends Base {
9294 * Register controller middleware
9395 */
9496 for ( const middleware of middlewaresInfo ) {
95- ( this . router [ middleware . method as keyof IRouter ] as Function ) (
97+ ( this . router [ middleware . method as keyof IRouter ] as RouteHandler ) (
9698 middleware . path ,
9799 new middleware . MiddlewareFunction (
98100 this . app ,
@@ -121,7 +123,7 @@ class AbstractController extends Base {
121123 if ( Object . prototype . toString . call ( routeObject ) !== '[object Object]' ) {
122124 // for support firect pass function instead of object
123125 routeObject = {
124- handler : routeObject as unknown as Function ,
126+ handler : routeObject as unknown as RouteHandler ,
125127 request : null ,
126128 query : null ,
127129 middleware : null ,
@@ -164,7 +166,9 @@ class AbstractController extends Base {
164166 // `Controller '${this.getConstructorName()}' register function '${fnName}' for method '${verb}' and path '${path}' Full path '${fullPath}'`,
165167 // );
166168
167- let additionalMiddlewares : any ;
169+ let additionalMiddlewares :
170+ | ReturnType < AbstractMiddleware [ 'getMiddleware' ] > [ ]
171+ | undefined ;
168172
169173 if ( routeAdditionalMiddlewares . length > 0 ) {
170174 additionalMiddlewares = Array . from (
@@ -174,7 +178,7 @@ class AbstractController extends Base {
174178 ) ;
175179 }
176180
177- ( this . router [ verb as keyof IRouter ] as Function ) (
181+ ( this . router [ verb as keyof IRouter ] as RouteHandler ) (
178182 path ,
179183 additionalMiddlewares || [ ] ,
180184 async ( req : FrameworkRequest , res : Response , next : NextFunction ) => {
0 commit comments