aaspai-schedkit
v0.1.0
Published
Universal scheduler & reminders with time zones, natural language, cron, RRULE. Express/Nest adapters + Mongo storage.
Downloads
4
Readme
schedkit-universal
Scheduling & Reminders you can reuse anywhere (NestJS, Express, any Node app). Supports:
- Time zones (IANA via Luxon)
- Natural language (
tomorrow 9am IST,in 15 minutes) via Chrono - Cron (
*/5 * * * *) via cron-parser - RRULE (
FREQ=DAILY;BYHOUR=9;BYMINUTE=0;BYSECOND=0;TZID=Asia/Kolkata) - One-shot reminders & recurring schedules
- Webhook dispatch + programmatic handlers
- Storage adapters: in-memory and MongoDB
- Express/Nest adapters, CLI worker
Install
npm i schedkit-universal luxon rrule cron-parser chrono-node mongodbDefine and run
import { createScheduler, MongoStorage } from "schedkit-universal/core";
import { MongoClient } from "mongodb";
const client = new MongoClient(process.env.MONGO_URI!);
await client.connect();
const storage = new MongoStorage(client.db(process.env.MONGO_DB));
const scheduler = createScheduler({
storage,
defaultTz: "Asia/Kolkata",
dispatch: async (job) => {
// YOUR handler: send email / push / whatever
console.log("Reminder fired:", job.name, job.payload);
}
});
scheduler.start(); // background tickCreate reminders (Express)
import express from "express";
import { createScheduleRouter } from "schedkit-universal/express";
const app = express();
app.use(express.json());
app.use("/api/schedule", createScheduleRouter(scheduler));POST /api/schedule/jobs
{
"name": "Daily standup",
"tz": "Asia/Kolkata",
"rrule": "FREQ=WEEKLY;BYHOUR=10;BYMINUTE=0;BYSECOND=0;BYDAY=MO,TU,WE,TH,FR",
"payload": { "room": "huddle-1" }
}or natural language
{ "name": "Hydrate!", "nlp": "in 20 minutes", "tz": "Asia/Kolkata" }or cron
{ "name": "Nightly job", "cron": "0 2 * * *", "tz": "UTC" }CLI
# run a worker loop using Mongo
npx schedkit worker --uri "$MONGO_URI" --db mydb --tz "Asia/Kolkata"
# schedule via CLI (natural language)
npx schedkit schedule --name "Demo" --nlp "tomorrow 9am" --tz "Asia/Kolkata"Notes
- DST-safe (RRULE/Luxon). For cron, we evaluate in the specified TZ each tick.
- Misfire protection via short lease; jobs won’t double-fire in multi-process setups (Mongo storage).
- You can export ICS later; extend
dispatchto email/calendar.
MIT
