From 3705893a629bccb314e5ca1601e4a3dfb672192f Mon Sep 17 00:00:00 2001 From: rybak Date: Tue, 28 Feb 2023 08:30:16 +0300 Subject: [PATCH] fix: Non exist getAllMethodNames from metadataScanner --- .../services/command-handler-finder.service.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/core/src/services/command-handler-finder.service.ts b/packages/core/src/services/command-handler-finder.service.ts index 45b9bd60..679c9645 100644 --- a/packages/core/src/services/command-handler-finder.service.ts +++ b/packages/core/src/services/command-handler-finder.service.ts @@ -12,9 +12,7 @@ export class CommandHandlerFinderService { ) {} async searchHandler(instance: InstanceType): Promise { - const methodNames = new Set( - this.metadataScanner.getAllMethodNames(Object.getPrototypeOf(instance)), - ); + const methodNames = new Set(this.getMethodsFromInstance(instance)); if (methodNames.size === 0) throw new Error( @@ -42,4 +40,17 @@ export class CommandHandlerFinderService { return handlerData.methodName; } + + private getMethodsFromInstance(instance: InstanceType) { + if (typeof this.metadataScanner.getAllMethodNames === 'function') { + return this.metadataScanner.getAllMethodNames( + Object.getPrototypeOf(instance), + ); + } + + // TODO: Remove later deprecated method + return this.metadataScanner.getAllFilteredMethodNames( + Object.getPrototypeOf(instance), + ); + } }