/*********************************************************************************************************************************************************************** * File Name : admin.cron.js * Type : Cron Registry — Admin side * Description : Aggregates and registers every admin-facing scheduled job. * Each job module in cron/jobs/ exports { name, schedule, run }: * name {string} – unique identifier, used in logs * schedule {string} – standard cron expression (node-cron) * run {function} – async () => void, the actual work * * To add a new admin-side cron job: * 1. Create cron/jobs/yourJob.cron.js exporting * { name, schedule, run } * 2. require() it below and add it to the `jobs` array * That's the only wiring required — server.js never needs to * change when admin-side jobs are added/removed. * * Currently registered: * - taskOverdue (cron/jobs/taskOverdue.cron.js) * * Author: Kenneth Obsequio (@lash0000) * Date Created: Jun. 17, 2026 ***********************************************************************************************************************************************************************/ const cron = require('node-cron'); const taskOverdue = require('./jobs/task_overdue.cron'); // ─── Registry — add future admin-side cron jobs here ───────────────────────── const jobs = [ taskOverdue, ]; // ─── Boot all registered admin-side jobs ────────────────────────────────────── function startAdminCronJobs() { const registered = []; jobs.forEach(({ name, schedule, run }) => { if (!cron.validate(schedule)) { console.error(`[CRON][ADMIN] Invalid schedule for "${name}": "${schedule}" — skipped.`); return; } cron.schedule(schedule, run); registered.push({ name, scope: 'ADMIN', schedule }); }); return registered; } module.exports = { startAdminCronJobs };