import { NextResponse } from "next/server";
import { getCurrentUser } from "@/lib/auth";
import { getVisibilityRecommendations } from "@/lib/services/ai-visibility-checker";
export const dynamic = "force-dynamic";
export const maxDuration = 30;
export async function POST(req: Request) {
  const user = await getCurrentUser();
  if (!user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  const body = await req.json().catch(() => null);
  if (!body?.brandId) return NextResponse.json({ error: "brandId required" }, { status: 400 });
  const recommendations = await getVisibilityRecommendations(body.brandId);
  return NextResponse.json({ recommendations });
}
