feat(speedtest): worker + hourly cron + history/run routes

Adds speedtest pg-boss worker with injectable runner for testing, hourly
cron enqueue, and /api/speedtest/history (GET) + /run (POST, owner-only) routes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-02 22:50:19 +10:00
parent c59d2407ed
commit e36a87a50e
7 changed files with 76 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import cron from 'node-cron';
import { runSync } from './sync_source_docs.js';
import { log } from '../log.js';
import { enqueue } from '../jobs/queue.js';
export function startCron() {
// Daily at 03:00 local time
@@ -12,5 +13,12 @@ export function startCron() {
log.error({ err: e }, 'cron sync.source_doc failed');
}
});
// Hourly speedtest
cron.schedule('0 * * * *', async () => {
try { await enqueue('speedtest', {}); log.info('cron speedtest enqueued'); }
catch (e) { log.error({ err: e }, 'cron speedtest failed'); }
});
log.info('cron started');
}