Skip to content

Commit 00922c4

Browse files
author
Leonardo Peixoto
committedOct 13, 2023
refactor: use setAllMethodNames method
1 parent c9940c2 commit 00922c4

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed
 

‎lib/schedule.explorer.ts

+21-8
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,30 @@ export class ScheduleExplorer implements OnModuleInit {
2727
];
2828
instanceWrappers.forEach((wrapper: InstanceWrapper) => {
2929
const { instance } = wrapper;
30+
3031
if (!instance || !Object.getPrototypeOf(instance)) {
3132
return;
3233
}
33-
this.metadataScanner.scanFromPrototype(
34-
instance,
35-
Object.getPrototypeOf(instance),
36-
(key: string) =>
37-
wrapper.isDependencyTreeStatic()
38-
? this.lookupSchedulers(instance, key)
39-
: this.warnForNonStaticProviders(wrapper, instance, key),
40-
);
34+
35+
const processMethod = (name: string) =>
36+
wrapper.isDependencyTreeStatic()
37+
? this.lookupSchedulers(instance, name)
38+
: this.warnForNonStaticProviders(wrapper, instance, name);
39+
40+
// TODO(v4): remove this after dropping support for nestjs v9.3.2
41+
if (!Reflect.has(this.metadataScanner, 'getAllMethodNames')) {
42+
this.metadataScanner.scanFromPrototype(
43+
instance,
44+
Object.getPrototypeOf(instance),
45+
processMethod,
46+
);
47+
48+
return;
49+
}
50+
51+
this.metadataScanner
52+
.getAllMethodNames(Object.getPrototypeOf(instance))
53+
.forEach(processMethod);
4154
});
4255
}
4356

0 commit comments

Comments
 (0)
Please sign in to comment.