@cronmate/scheduler
v1.0.2
Published
Developer-friendly async task scheduler with timezone support
Maintainers
Readme
🕒 TypeScript Scheduler
A simple, developer-friendly, async-aware scheduler for Node.js, built with TypeScript, node-cron, and moment-timezone.
✅ Features
- ⏱ Easy-to-use methods like
.runEveryMinute(),.runDailyAt(), etc. - 🌍 Full timezone support using IANA timezones (e.g.,
"America/New_York") - 🧠 Type-safe: auto-complete for valid timezone strings
- 🔄 Async/await ready
- 🎨 Colorful console output with
chalk - 🧪 Returns
ScheduledTaskso you can.stop()manually
🚀 Installation
npm install @cronmate/scheduler🛠 Usage
import Scheduler from "@cronmate/scheduler";
const scheduler = new Scheduler("Europe/Belgrade");
// Run every second
scheduler.runEverySecond(async () => {
console.log("Hello every second!");
});
// Run daily at 9:30 AM
scheduler.runDailyAt(9, 30, async () => {
await sendDailyEmails();
});🧩 API
Constructor
new Scheduler(timezone?: Timezone)timezoneis optional and defaults to your system timezone.- Fully type-safe and auto-suggested.
Schedule Methods
| Method | Runs at |
| ---------------------- | ----------------------------------- |
| runEverySecond(fn) | Every second |
| runEveryMinute(fn) | Every minute |
| runEveryHour(fn) | At the start of every hour |
| runEveryDay(fn) | At midnight every day |
| runEveryWeek(fn) | Every Sunday at midnight |
| runEveryMonth(fn) | On the 1st of every month at 00:00 |
| runDailyAt(h, m, fn) | Every day at specific hour & minute |
🛑 Stopping a Job
const task = await scheduler.runEveryMinute(() => {
console.log("Ping");
});
task.stop(); // stops the scheduled job🧠 Credits
- Built with
node-cron - Timezone support from
moment-timezone - Logging with
chalk
📄 License
MIT
