cron works now, poc

This commit is contained in:
Jacob Nguyen
2024-05-15 16:52:33 -05:00
parent d905f08993
commit 203e8c8ecf
5 changed files with 17 additions and 12 deletions

View File

@@ -52,14 +52,17 @@ export class Cron extends EventEmitter {
modules: Map<string, CronEventCommand> = new Map();
private sanityCheck(eventName: string | symbol) : asserts eventName is string {
if(typeof eventName === 'symbol') throw Error("Cron cannot add symbol based listener")
if(!cron.validate(eventName)) {
throw Error("Invalid cron expression while adding")
}
}
addCronModule(module: Module) {
if(module.type !== EventType.Cron) {
throw Error("Can only add cron modules");
}
//@ts-ignore
if(!cron.validate(module.pattern)) {
throw Error("Invalid cron expression while adding")
}
this.modules.set(module.name!, module as CronEventCommand);
}
addListener(eventName: string | symbol, listener: AnyFunction): this {