mcp-daily-tasks
Version:
MCP para manejar tareas y resúmenes con integración ClickUp.
21 lines (20 loc) • 606 B
JavaScript
import cron from "node-cron";
const scheduledJobs = {};
export function scheduleTask(task, handler) {
if (scheduledJobs[task.id]) {
scheduledJobs[task.id].stop();
}
scheduledJobs[task.id] = cron.schedule(task.cronTime, async () => {
await handler(task);
});
}
export function unscheduleTask(id) {
if (scheduledJobs[id]) {
scheduledJobs[id].stop();
delete scheduledJobs[id];
}
}
export function rescheduleAll(tasks, handler) {
Object.keys(scheduledJobs).forEach(id => unscheduleTask(id));
tasks.forEach(task => scheduleTask(task, handler));
}