feat: add multi-app support with app switcher, per-app branding, and filtered queries
Apps share the same backend, API keys, and publishing flow but each gets its own branding (name, colors, icon, app URL), knowledge files (brand identity, product info, platform guidelines), and campaigns. The pipeline dynamically writes _knowledge/ files and copies app assets before each run. - Add App model with slug, colors, appUrl, and knowledge markdown fields - Add appId FK to Campaign, seed honeyDue as first app with existing knowledge - App switcher dropdown in sidebar with icon previews - Filter campaigns, stats, and assets by active app (cookie-based) - De-hardcode lib/claude.ts: AppConfig interface, templated prompts, dynamic _knowledge/ and Remotion asset copying - App management pages (list, create, edit) with icon upload and color pickers - Asset library sort options (newest, oldest, name, platform, type) - Asset cards show creation date - Remotion HoneyDueAd accepts colors/appName props Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
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,
|
||||
},
|
||||
});
|
||||
|
||||
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 });
|
||||
}
|
||||
Reference in New Issue
Block a user