Files
starr-philproperties/cron/client.cron.js
T
kennethobsequio 439bb33f77 ready to test
Testing

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
2026-06-22 10:06:58 +08:00

36 lines
1.7 KiB
JavaScript

/***********************************************************************************************************************************************************************
* File Name : client.cron.js
* Type : Cron Registry — Client side
* Description : Aggregates and registers every client-facing scheduled job.
* Same shape as admin.cron.js — each job module exports
* { name, schedule, run }, listed in the `jobs` array below.
*
* Currently registered:
* - userNotifications (cron/jobs/user_notifications.cron.js)
*
* Author: Kenneth Obsequio (@lash0000)
* Date Created: Jun. 17, 2026
***********************************************************************************************************************************************************************/
const cron = require('node-cron');
const userNotifications = require('./jobs/user_notifications.cron');
// ─── Registry — add future client-side cron jobs here ────────────────────────
const jobs = [
userNotifications,
];
// ─── Boot all registered client-side jobs ─────────────────────────────────────
function startClientCronJobs() {
const registered = [];
jobs.forEach(({ name, schedule, run }) => {
if (!cron.validate(schedule)) {
console.error(`[CRON][CLIENT] Invalid schedule for "${name}": "${schedule}" — skipped.`);
return;
}
cron.schedule(schedule, run);
registered.push({ name, scope: 'CLIENT', schedule });
});
return registered;
}
module.exports = { startClientCronJobs };