fastify-cron
Version:
Run cron jobs alongside your Fastify server
31 lines (30 loc) • 1.03 kB
TypeScript
/// <reference types="node" />
import { CronJob, CronJobParameters } from 'cron';
import type { FastifyInstance, FastifyPluginAsync } from 'fastify';
export declare type Job = CronJob & {
readonly name?: string;
};
declare module 'fastify' {
interface FastifyInstance {
cron: CronDecorator;
}
}
export declare type Params = Omit<CronJobParameters, 'onTick' | 'onComplete'> & {
onTick: (server: FastifyInstance) => void;
onComplete?: (server: FastifyInstance) => void;
startWhenReady?: boolean;
name?: string;
};
export interface CronDecorator {
readonly jobs: Job[];
createJob: (params: Params) => Job;
getJobByName: (name: string) => Job | undefined;
startAllJobs: () => void;
stopAllJobs: () => void;
}
export declare type FalsyValue = undefined | null | false;
export interface Config {
jobs?: (Params | FalsyValue)[];
}
declare const _default: FastifyPluginAsync<Config, import("http").Server, import("fastify").FastifyTypeProviderDefault>;
export default _default;