// Author: Simon-Pierre Boucher // Contact: contact@spboucher.ai // Project: chat.spboucher.ai import { NextResponse } from "next/server"; import { requireSession } from "@/lib/auth/guard"; import { syncCatalog } from "@/lib/catalog"; export const runtime = "nodejs"; export async function POST() { const { unauthorized } = await requireSession(); if (unauthorized) return unauthorized; try { const result = await syncCatalog(); return NextResponse.json(result); } catch { return NextResponse.json( { error: "Catalog sync failed. Check connectivity and retry." }, { status: 502 } ); } }