1.0.2 โ€ข Published 8 months ago

@cronmate/scheduler v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

๐Ÿ•’ 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 ScheduledTask so 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)
  • timezone is optional and defaults to your system timezone.
  • Fully type-safe and auto-suggested.

Schedule Methods

MethodRuns 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


๐Ÿ“„ License

MIT

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago