
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@toolkit-p2p/cron
Advanced tools
Distributed cron job scheduler for P2P applications with standard 5-field cron expression support.
npm install @toolkit-p2p/cron
import { CronScheduler } from '@toolkit-p2p/cron';
// Create scheduler
const scheduler = new CronScheduler();
// Add a job
await scheduler.addJob({
name: 'daily-cleanup',
schedule: '0 0 * * *', // Daily at midnight
handler: async (context) => {
console.log(`Running ${context.jobName} at ${new Date(context.executionTime)}`);
// Your job logic here
},
metadata: { priority: 'high' },
});
// Query jobs
const jobs = scheduler.queryJobs({ enabled: true });
// Get statistics
const stats = scheduler.getStats();
console.log(`Total jobs: ${stats.totalJobs}, Enabled: ${stats.enabledJobs}`);
The scheduler supports standard 5-field cron expressions:
* * * * *
│ │ │ │ │
│ │ │ │ └─ Day of week (0-6, 0=Sunday)
│ │ │ └─── Month (1-12)
│ │ └───── Day of month (1-31)
│ └─────── Hour (0-23)
└───────── Minute (0-59)
* * * * * - Every minute0 * * * * - Every hour0 0 * * * - Daily at midnight0 0 * * 0 - Every Sunday at midnight*/5 * * * * - Every 5 minutes0,30 * * * * - Every hour at 0 and 30 minutes0-15 * * * * - First 15 minutes of every hourconst scheduler = new CronScheduler(options?: SchedulerOptions);
Options:
autoStart - Auto-start scheduler (default: true)checkIntervalMs - Job check interval (default: 1000ms)maxConcurrentJobs - Max concurrent jobs (default: 10)enablePersistence - Enable persistence (default: false)storageAdapter - Storage adapter for persistencedefaultTimezone - Default timezone (default: 'UTC')addJob(options) - Add a new jobremoveJob(jobId) - Remove a jobgetJob(jobId) - Get job by IDenableJob(jobId) - Enable a jobdisableJob(jobId) - Disable a jobqueryJobs(query?) - Query jobs with filtersgetStats() - Get scheduler statisticsstart() - Start the schedulerstop() - Stop the schedulerinterface CreateJobOptions {
name: string;
schedule: string;
handler: (context: JobContext) => void | Promise<void>;
metadata?: Record<string, unknown>;
enabled?: boolean;
maxRetries?: number;
retryDelayMs?: number;
timeoutMs?: number;
timezone?: string;
}
Job handlers receive a context object:
interface JobContext {
jobId: string;
jobName: string;
scheduledTime: number;
executionTime: number;
runCount: number;
metadata?: Record<string, unknown>;
signal?: AbortSignal;
}
pnpm test
MIT
FAQs
Distributed cron job scheduler for P2P applications
We found that @toolkit-p2p/cron 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.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.