gitdataai/admin/src/app/api/cron-initialize/route.ts
ZhenYi 86c7810fd9 feat(admin): add node-cron daily scheduler for reports
- node-cron scheduler runs at 00:00 UTC every day
- Custom server.js auto-starts cron on npm start
- isRunning lock prevents concurrent report runs
- cron-initialize API for manual cron control
- Updated npm start to use server.js entry point
2026-04-22 10:23:21 +08:00

18 lines
426 B
TypeScript

import { NextResponse } from "next/server";
import { startDailyReportCron } from "@/lib/daily-report-cron";
export const runtime = "nodejs";
// Guard: only start cron once per server instance
let started = false;
export async function GET() {
if (started) {
return NextResponse.json({ status: "already_started" });
}
started = true;
startDailyReportCron();
return NextResponse.json({ status: "started" });
}