expressots-cron
Version:
Expressots - Cron Provider (expressots-cron)
32 lines (31 loc) • 1.28 kB
TypeScript
import { IProvider } from "@expressots/core";
import { ICron, ScheduleOptions } from "./cron.interface";
import { CronJob } from "cron";
export declare class CronProvider implements IProvider, ICron {
readonly author: string;
readonly name: string;
readonly version: string;
readonly repo: string;
private readonly report;
constructor();
/**
* Creates a new task to execute the given function when the cron expression ticks.
* @param cronExpression the cron expression to schedule against
* @param func the function to execute. Can be a string path to a function, or a function itself
* @param [options] the options to pass to the cron scheduler
* @returns the scheduled task
*/
schedule(cronExpression: string, func: () => void, options?: ScheduleOptions): CronJob;
/**
* Get the list of tasks created using the `schedule` function
* @returns {Map<string, ScheduledTask>} a map of task names to tasks
*/
getTasks(): Map<string, CronJob>;
/**
* Get a specific task created using the `schedule` function
* @param name the name of the task to retrieve
* @returns the scheduled task
* @throws {Error} if the task is not found
*/
getTask(name: string): CronJob;
}