mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
ready to test
Testing Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
/***********************************************************************************************************************************************************************
|
||||
* 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 };
|
||||
Reference in New Issue
Block a user