
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
jsm-scheduler
Advanced tools
A lightweight and intuitive job scheduler library for Node.js. Leverage decorators to define and manage cron jobs in a clean and scalable way.
@Cron
, @Delay
, @MaxFreezeTime
, etc.@ProductionOnly
.node-schedule
library.Install the package using npm:
npm install jsm-scheduler
Or with yarn:
yarn add jsm-scheduler
Here is how you can use jsm-scheduler
to define and manage scheduled tasks:
import { Scheduler, Cron, Delay, MaxFreezeTime, TaskName, ProductionOnly } from 'jsm-scheduler';
@Scheduler
class TaskScheduler {
@Cron('0 0 0 * * *')
@Delay(1000) // Adds a 1-second delay before execution
@MaxFreezeTime(15 * 60 * 1000) // Ensures tasks are frozen for a maximum of 15 minutes
@TaskName('midnightTask') // Custom task name
@ProductionOnly() // Executes only in production environments
async midnightTask() {
console.log('Executing midnight task logic...');
// Add your custom task logic here
}
}
Simply import the file containing your scheduler class to initialize it:
// index.ts
import './task-scheduler'; // Import your scheduler class
When you run your application, the scheduler will automatically register and execute the defined jobs.
You can define multiple jobs with different configurations:
import { Scheduler, Cron, Delay, TaskName } from 'jsm-scheduler';
@Scheduler
class AdvancedScheduler {
@Cron('*/10 * * * * *') // Runs every 10 seconds
@TaskName('heartbeat')
async heartbeatTask() {
console.log('Heartbeat task running...');
}
@Cron('0 0 12 * * *') // Runs every day at noon
async dailyReportTask() {
console.log('Generating daily report...');
// Your report generation logic here
}
}
@Cron(cron: string)
Defines the cron expression for the task.
@Delay(delay: number)
Adds a delay (in milliseconds) before the task execution.
@MaxFreezeTime(maxFreezeTime: number)
Ensures a task cannot be frozen for more than the specified time (in milliseconds).
@TaskName(name: string)
Sets a custom name for the task.
@ProductionOnly()
Restricts the execution of the task to production environments (NODE_ENV=production
).
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! If you'd like to report issues or submit pull requests, please visit the GitHub repository.
Developed by Reevo Solutions.
FAQs
A library to handle scheduling in JavaScript applications.
The npm package jsm-scheduler receives a total of 71 weekly downloads. As such, jsm-scheduler popularity was classified as not popular.
We found that jsm-scheduler demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.