@signalbox/schedule
v0.2.3
Published
signalbox plugin: schedule one-shot and cron jobs (timezone-aware, via Croner)
Readme
@signalbox/schedule
signalbox plugin: schedule one-shot and cron jobs, timezone-aware, via Croner.
Part of signalbox — see the full documentation.
Install
npm install @signalbox/scheduleUsage
import { schedulePlugin } from "@signalbox/schedule"
const plugins = {
schedule: schedulePlugin(),
}
// in a workflow:
ctx.plugins.schedule.cron("0 9 * * 1", { timezone: "Europe/Warsaw" }, () => {
ctx.log("Monday 9am")
})
ctx.plugins.schedule.at(new Date(Date.now() + 60_000), () => {
ctx.log("one minute later")
})cron(expression, options, fn)— run on a cron schedule;options.timezoneis an IANA zone (defaults to host local time).at(date, fn)— run once at a date (a past date never fires).next(expression, options?, from?)— the next run at or afterfrom, ornull.
Each returns a ScheduleHandle you can stop; jobs are torn down with the app.
License
MIT
