diff --git a/src/decorators/Controller.ts b/src/decorators/Controller.ts index fcab684..fdc0eb7 100644 --- a/src/decorators/Controller.ts +++ b/src/decorators/Controller.ts @@ -74,17 +74,15 @@ export function Controller() // Get the 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) => target.prototype[method](req, res, next); - } - // Get the path const path = Reflect.getMetadata(GET_METADATA_KEY, target.prototype, method); // Bind the method to the class instance - app.get(path, fn.bind(controller)); + app.use((req, res, next) => { + if(req.path === path && req.method === 'GET') { + fn.bind(controller)(req, res, next); + } + }); }); // Loop over all the methods in the decorated class looking for methods that use the POST decorator