Replace custom setInterval scheduler with croner

Swap the hand-rolled Scheduler class (setInterval-based) for croner,
a battle-tested cron library with overlap protection and proper cron
expressions. Consolidate lib/jobs/ into a single lib/cron.ts and
remove the unused admin jobs API route.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-03 18:52:05 -05:00
co-authored by Claude Opus 4.6
parent 2ee20a6aff
commit 0f345c8cd6
8 changed files with 120 additions and 173 deletions
-25
View File
@@ -1,25 +0,0 @@
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { registerJobs } from "@/lib/jobs/registry";
import { scheduler } from "@/lib/jobs/scheduler";
// Ensure jobs are registered for manual triggering
registerJobs();
export async function POST(
_req: NextRequest,
{ params }: { params: Promise<{ name: string }> },
) {
const { name } = await params;
const jobNames = scheduler.getJobNames();
if (!jobNames.includes(name)) {
return NextResponse.json(
{ error: `Unknown job: ${name}. Available: ${jobNames.join(", ")}` },
{ status: 400 },
);
}
await scheduler.runNow(name);
return NextResponse.json({ ok: true, job: name });
}