807dfc539b
- Add thumbs-down feedback modal and preference API endpoint - Add AI UGC video platforms research doc - Add ReflectAd Remotion composition with public flow assets - Add gemini-ad-designer and poster-ad-designer pipeline skills - Add research_reflect_v1.1 pipeline script Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import { auth } from "@/lib/auth";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
export async function GET(
|
|
_request: Request,
|
|
{ params }: { params: Promise<{ slug: string }> }
|
|
) {
|
|
const session = await auth();
|
|
if (!session) return new Response("Unauthorized", { status: 401 });
|
|
|
|
const { slug } = await params;
|
|
const app = await prisma.app.findUnique({
|
|
where: { slug },
|
|
include: { _count: { select: { campaigns: true } } },
|
|
});
|
|
|
|
if (!app) return Response.json({ error: "Not found" }, { status: 404 });
|
|
return Response.json(app);
|
|
}
|
|
|
|
export async function PATCH(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ slug: string }> }
|
|
) {
|
|
const session = await auth();
|
|
if (!session) return new Response("Unauthorized", { status: 401 });
|
|
|
|
const { slug } = await params;
|
|
const body = await request.json();
|
|
|
|
const app = await prisma.app.findUnique({ where: { slug } });
|
|
if (!app) return Response.json({ error: "Not found" }, { status: 404 });
|
|
|
|
const updated = await prisma.app.update({
|
|
where: { slug },
|
|
data: {
|
|
name: body.name ?? undefined,
|
|
description: body.description ?? undefined,
|
|
appUrl: body.appUrl ?? undefined,
|
|
primaryColor: body.primaryColor ?? undefined,
|
|
accentColor: body.accentColor ?? undefined,
|
|
darkBg: body.darkBg ?? undefined,
|
|
brandIdentity: body.brandIdentity ?? undefined,
|
|
productInfo: body.productInfo ?? undefined,
|
|
platformGuidelines: body.platformGuidelines ?? undefined,
|
|
stylePreferences: body.stylePreferences ?? undefined,
|
|
},
|
|
});
|
|
|
|
return Response.json(updated);
|
|
}
|
|
|
|
export async function DELETE(
|
|
_request: Request,
|
|
{ params }: { params: Promise<{ slug: string }> }
|
|
) {
|
|
const session = await auth();
|
|
if (!session) return new Response("Unauthorized", { status: 401 });
|
|
|
|
const { slug } = await params;
|
|
const app = await prisma.app.findUnique({ where: { slug } });
|
|
if (!app) return Response.json({ error: "Not found" }, { status: 404 });
|
|
|
|
// Check for campaigns
|
|
const campaignCount = await prisma.campaign.count({ where: { appId: app.id } });
|
|
if (campaignCount > 0) {
|
|
return Response.json(
|
|
{ error: `Cannot delete app with ${campaignCount} campaign(s). Remove campaigns first.` },
|
|
{ status: 409 }
|
|
);
|
|
}
|
|
|
|
await prisma.app.delete({ where: { slug } });
|
|
return Response.json({ deleted: true });
|
|
}
|