mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 06:15:39 -04:00
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:
@@ -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 });
|
||||
}
|
||||
Reference in New Issue
Block a user