mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
36 lines
1.7 KiB
JavaScript
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 }; |