mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
* Initial * Progress * Fix * Progress * Notifications list page * BADGE_MANAGER_ADDED * Mark as seen initial * Split tables * Progress * Fix styles * Push notifs initial * Progress * Rename * Routines * Progress * Add e2e tests * Done? * Try updating actions * Consistency * Dep fix * A couple fixes
31 lines
580 B
TypeScript
31 lines
580 B
TypeScript
import { logger } from "../utils/logger";
|
|
|
|
export class Routine {
|
|
private name;
|
|
private func;
|
|
|
|
constructor({
|
|
name,
|
|
func,
|
|
}: {
|
|
name: string;
|
|
func: () => Promise<void>;
|
|
}) {
|
|
this.name = name;
|
|
this.func = func;
|
|
}
|
|
|
|
async run() {
|
|
logger.info(`Running routine: ${this.name}`);
|
|
const startTime = performance.now();
|
|
try {
|
|
await this.func();
|
|
} catch (error) {
|
|
logger.error(`Error running routine ${this.name}: ${error}`);
|
|
return;
|
|
}
|
|
const endTime = performance.now();
|
|
logger.info(`Routine ${this.name} completed in ${endTime - startTime}ms`);
|
|
}
|
|
}
|