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,69 @@
|
||||
import { auth } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { mkdirSync } from "fs";
|
||||
import path from "path";
|
||||
|
||||
export async function GET() {
|
||||
const session = await auth();
|
||||
if (!session) return new Response("Unauthorized", { status: 401 });
|
||||
|
||||
const apps = await prisma.app.findMany({
|
||||
orderBy: { createdAt: "asc" },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
slug: true,
|
||||
description: true,
|
||||
primaryColor: true,
|
||||
accentColor: true,
|
||||
darkBg: true,
|
||||
createdAt: true,
|
||||
_count: { select: { campaigns: true } },
|
||||
},
|
||||
});
|
||||
|
||||
return Response.json(apps);
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const session = await auth();
|
||||
if (!session) return new Response("Unauthorized", { status: 401 });
|
||||
|
||||
const body = await request.json();
|
||||
const { name, slug, description, appUrl, primaryColor, accentColor, darkBg, brandIdentity, productInfo, platformGuidelines } = body;
|
||||
|
||||
if (!name || !slug) {
|
||||
return Response.json({ error: "Name and slug are required" }, { status: 400 });
|
||||
}
|
||||
|
||||
// Validate slug format
|
||||
if (!/^[a-z0-9-]+$/.test(slug)) {
|
||||
return Response.json({ error: "Slug must be lowercase alphanumeric with hyphens only" }, { status: 400 });
|
||||
}
|
||||
|
||||
const existing = await prisma.app.findUnique({ where: { slug } });
|
||||
if (existing) {
|
||||
return Response.json({ error: "An app with this slug already exists" }, { status: 409 });
|
||||
}
|
||||
|
||||
const app = await prisma.app.create({
|
||||
data: {
|
||||
name,
|
||||
slug,
|
||||
description: description || null,
|
||||
appUrl: appUrl || null,
|
||||
primaryColor: primaryColor || "#0079FF",
|
||||
accentColor: accentColor || "#FF9400",
|
||||
darkBg: darkBg || "#1a1a2e",
|
||||
brandIdentity: brandIdentity || null,
|
||||
productInfo: productInfo || null,
|
||||
platformGuidelines: platformGuidelines || null,
|
||||
},
|
||||
});
|
||||
|
||||
// Create filesystem structure
|
||||
const pipelineRoot = process.env.PIPELINE_ROOT || path.join(process.cwd(), "pipeline");
|
||||
mkdirSync(path.join(pipelineRoot, "apps", slug, "screenshots"), { recursive: true });
|
||||
|
||||
return Response.json(app, { status: 201 });
|
||||
}
|
||||
Reference in New Issue
Block a user