28 lines
743 B
TypeScript
28 lines
743 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { requirePlatformRole } from "@/lib/session";
|
|
import {
|
|
getLastSuccessfulCronRuns,
|
|
listRecentCronRuns,
|
|
} from "@/lib/db";
|
|
|
|
/**
|
|
* GET /api/admin/cron/runs
|
|
*
|
|
* Returns recent cron run history plus per-kind "last successful"
|
|
* summary for the admin /admin/cron dashboard.
|
|
*
|
|
* Response: { recent: CronRun[]; lastSuccess: { monthlyIssue, reminders } }
|
|
*/
|
|
export async function GET() {
|
|
try {
|
|
await requirePlatformRole();
|
|
} catch {
|
|
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
|
}
|
|
const [recent, lastSuccess] = await Promise.all([
|
|
listRecentCronRuns(30),
|
|
getLastSuccessfulCronRuns(),
|
|
]);
|
|
return NextResponse.json({ recent, lastSuccess });
|
|
}
|