import { NextResponse } from "next/server"; import { isSchedulerRequestAuthorized } from "../../../scheduler/auth"; import { runSchedulerTick } from "../../../scheduler/runTick"; export const dynamic = "force-dynamic"; // The cron-driven heartbeat. A lightweight external client (common/bin/sync-tick.ts) // POSTs here on a schedule; the server decides which channels are due and queues // them through the existing job machinery. See common/jobs/syncScheduler.ts. export async function POST(req: Request) { if (!isSchedulerRequestAuthorized(req)) { return NextResponse.json({ error: "unauthorized" }, { status: 401 }); } const result = await runSchedulerTick(); return NextResponse.json(result); }