chore: relocate backend into apps/api ahead of monorepo merge

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-24 12:20:40 +08:00
co-authored by Claude Sonnet 5
parent af44598df6
commit eaa6d2276a
388 changed files with 0 additions and 13998 deletions
+64
View File
@@ -0,0 +1,64 @@
/***********************************************************************************************************************************************************************
* 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.
*
* taskOverdue is settings-backed (see cronRegistry.util.js) —
* its schedule/enabled state lives in cron_notification_settings
* and is configurable from /admin/notifications/settings without
* a restart. liftExpiredBans is not notification-related, so it
* stays on a plain hardcoded schedule.
*
* Currently registered:
* - taskOverdue (cron/jobs/task_overdue.cron.js) — settings-backed
* - liftExpiredBans (cron/jobs/lift_expired_bans.cron.js)
* - retryStuckTranscodes (cron/jobs/retry_stuck_transcodes.cron.js)
*
* Author: Kenneth Obsequio (@lash0000)
* Date Created: Jun. 17, 2026
***********************************************************************************************************************************************************************/
const cron = require('node-cron');
const taskOverdue = require('./jobs/task_overdue.cron');
const liftExpiredBans = require('./jobs/lift_expired_bans.cron');
const retryStuckTranscodes = require('./jobs/retry_stuck_transcodes.cron');
const { startSettingsBackedJobs } = require('./cronRegistry.util');
// ─── Registry — add future admin-side cron jobs here ─────────────────────────
const settingsBackedJobs = [
taskOverdue,
];
// Plain hardcoded-schedule jobs (not tied to any notification setting).
const plainJobs = [
liftExpiredBans,
retryStuckTranscodes,
];
// ─── Boot all registered admin-side jobs ──────────────────────────────────────
async function startAdminCronJobs() {
const registered = await startSettingsBackedJobs(settingsBackedJobs, 'ADMIN');
for (const job of plainJobs) {
if (!cron.validate(job.schedule)) {
console.error(`[CRON][ADMIN] Invalid schedule for "${job.name}": "${job.schedule}" — skipped.`);
continue;
}
cron.schedule(job.schedule, job.run);
registered.push({ name: job.name, scope: 'ADMIN', schedule: job.schedule });
}
return registered;
}
module.exports = { startAdminCronJobs };