Skip to content

Commit

Permalink
refactor: use setAllMethodNames method
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Peixoto committed Oct 13, 2023
1 parent c9940c2 commit 00922c4
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions lib/schedule.explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,30 @@ export class ScheduleExplorer implements OnModuleInit {
];
instanceWrappers.forEach((wrapper: InstanceWrapper) => {
const { instance } = wrapper;

if (!instance || !Object.getPrototypeOf(instance)) {
return;
}
this.metadataScanner.scanFromPrototype(
instance,
Object.getPrototypeOf(instance),
(key: string) =>
wrapper.isDependencyTreeStatic()
? this.lookupSchedulers(instance, key)
: this.warnForNonStaticProviders(wrapper, instance, key),
);

const processMethod = (name: string) =>
wrapper.isDependencyTreeStatic()
? this.lookupSchedulers(instance, name)
: this.warnForNonStaticProviders(wrapper, instance, name);

// TODO(v4): remove this after dropping support for nestjs v9.3.2
if (!Reflect.has(this.metadataScanner, 'getAllMethodNames')) {
this.metadataScanner.scanFromPrototype(
instance,
Object.getPrototypeOf(instance),
processMethod,
);

return;
}

this.metadataScanner
.getAllMethodNames(Object.getPrototypeOf(instance))
.forEach(processMethod);
});
}

Expand Down

0 comments on commit 00922c4

Please sign in to comment.