Schedule save auto-approves and publishes when due; cron recovers stale jobs every 5m. Drive sync auto-matches client folders under Clientes when not linked. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
/**
|
|
* Cron: publish due creative_pipeline rows to Meta IG+FB.
|
|
*
|
|
* Auth: Authorization: Bearer $CRON_SECRET
|
|
* curl -sS -H "Authorization: Bearer $CRON_SECRET" \
|
|
* "https://app.4ventures.es/api/cron/pipeline-publish"
|
|
*/
|
|
import { NextRequest, NextResponse } from 'next/server';
|
|
import { assertCronAuth } from '@/lib/cron-auth';
|
|
import { processDuePipelinePublishes } from '@/lib/pipeline-publish-worker';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
export const runtime = 'nodejs';
|
|
export const maxDuration = 120;
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const denied = assertCronAuth(req);
|
|
if (denied) return denied;
|
|
|
|
const limit = Number(req.nextUrl.searchParams.get('limit') || 10);
|
|
const dryRun = req.nextUrl.searchParams.get('dry') === '1';
|
|
const tenantId =
|
|
req.nextUrl.searchParams.get('tenantId')?.trim() || undefined;
|
|
|
|
const out = await processDuePipelinePublishes({ limit, dryRun, tenantId });
|
|
if (!out.ok && out.error) {
|
|
return NextResponse.json(
|
|
{ error: out.error },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
return NextResponse.json(out);
|
|
}
|
|
|
|
export async function POST(req: NextRequest) {
|
|
return GET(req);
|
|
}
|