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
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 43s
This commit is contained in:
parent
02878a3069
commit
868a8aaadb
1 changed files with 8 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { Application, NextFunction } from 'express';
|
import { Application, Request, Response, NextFunction } from 'express';
|
||||||
|
|
||||||
import { BaseController } from '../controllers/BaseController';
|
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))
|
.filter((method) => Reflect.getMetadata(GET_METADATA_KEY, target.prototype, method))
|
||||||
.map((method) => {
|
.map((method) => {
|
||||||
// Get the 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
|
// Get the path
|
||||||
const path = Reflect.getMetadata(GET_METADATA_KEY, target.prototype, method);
|
const path = Reflect.getMetadata(GET_METADATA_KEY, target.prototype, method);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue