diff --git a/src/decorators/Controller.ts b/src/decorators/Controller.ts index 732ff17..346ad84 100644 --- a/src/decorators/Controller.ts +++ b/src/decorators/Controller.ts @@ -104,7 +104,7 @@ export function Controller(b // Loop over all the methods in the decorated class looking for methods that use the GET decorator Object.getOwnPropertyNames(target.prototype) // Find all methods that have a Get metadata key (GET decorator) - .filter((method) => Reflect.getMetadata(GET_METADATA_KEY, target.prototype, method)) + .filter((method) => typeof Reflect.getMetadata(GET_METADATA_KEY, target.prototype, method) !== 'undefined') .map((method) => { // Get the method let fn = target.prototype[method]; @@ -165,7 +165,7 @@ export function Controller(b // Loop over all the methods in the decorated class looking for methods that use the POST decorator Object.getOwnPropertyNames(target.prototype) // Find all methods that have a Post metadata key (POST decorator) - .filter((method) => Reflect.getMetadata(POST_METADATA_KEY, target.prototype, method)) + .filter((method) => typeof Reflect.getMetadata(POST_METADATA_KEY, target.prototype, method) !== 'undefined') .map((method) => { // Get the method const fn = target.prototype[method]; @@ -217,7 +217,7 @@ export function Controller(b // Loop over all the methods in the decorated class looking for methods that use the `@PUT` decorator Object.getOwnPropertyNames(target.prototype) // Find all methods that have the associated metadata key (`@PUT` decorator) - .filter((method) => Reflect.getMetadata(PUT_METADATA_KEY, target.prototype, method)) + .filter((method) => typeof Reflect.getMetadata(PUT_METADATA_KEY, target.prototype, method) !== 'undefined') .map((method) => { // Get the method const fn = target.prototype[method]; @@ -264,7 +264,7 @@ export function Controller(b // Loop over all the methods in the decorated class looking for methods that use the `@DELETE` decorator Object.getOwnPropertyNames(target.prototype) // Find all methods that have the associated metadata key (`@DELETE` decorator) - .filter((method) => Reflect.getMetadata(DELETE_METADATA_KEY, target.prototype, method)) + .filter((method) => typeof Reflect.getMetadata(DELETE_METADATA_KEY, target.prototype, method) !== 'undefined') .map((method) => { // Get the method const fn = target.prototype[method];