Attempting change to Controller's setup to see if it fixes error handling problem
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 43s

This commit is contained in:
Alan Bridgeman 2025-06-24 07:22:34 -05:00
parent 02878a3069
commit 868a8aaadb

View file

@ -1,4 +1,4 @@
import { Application, NextFunction } from 'express';
import { Application, Request, Response, NextFunction } from 'express';
import { BaseController } from '../controllers/BaseController';
@ -72,7 +72,13 @@ export function Controller<T extends { new (...args: any[]): BaseController }>()
.filter((method) => Reflect.getMetadata(GET_METADATA_KEY, target.prototype, method))
.map((method) => {
// Get the method
const fn = target.prototype[method];
let fn = target.prototype[method];
// If `fn` is the two parameter variant force it to be a three parameter variant
// This is because of how error handling is done in the framework (based on how Express does it)
if(fn.length === 2) {
fn = (req: Request, res: Response, next: NextFunction) => fn(req, res, next);
}
// Get the path
const path = Reflect.getMetadata(GET_METADATA_KEY, target.prototype, method);