80a1ffbe4d
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>
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { auth } from "@/lib/auth";
|
|
import { getActiveApp } from "@/lib/active-app";
|
|
import { writeFile, mkdir } from "fs/promises";
|
|
import path from "path";
|
|
import { randomUUID } from "crypto";
|
|
|
|
const PIPELINE_ROOT =
|
|
process.env.PIPELINE_ROOT || path.join(process.cwd(), "pipeline");
|
|
|
|
export async function POST(request: Request) {
|
|
const session = await auth();
|
|
if (!session) return new Response("Unauthorized", { status: 401 });
|
|
|
|
const formData = await request.formData();
|
|
const files = formData.getAll("files") as File[];
|
|
|
|
if (files.length === 0) {
|
|
return Response.json({ error: "No files provided" }, { status: 400 });
|
|
}
|
|
|
|
// Determine upload path based on active app
|
|
const activeApp = await getActiveApp();
|
|
const screenshotsDir = activeApp
|
|
? path.join(PIPELINE_ROOT, "apps", activeApp.slug, "screenshots")
|
|
: path.join(PIPELINE_ROOT, "assets", "screenshots");
|
|
const relativeBase = activeApp
|
|
? `apps/${activeApp.slug}/screenshots`
|
|
: "assets/screenshots";
|
|
|
|
await mkdir(screenshotsDir, { recursive: true });
|
|
|
|
const uploaded: { fileName: string; path: string }[] = [];
|
|
|
|
for (const file of files) {
|
|
if (!file.type.startsWith("image/")) continue;
|
|
|
|
const ext = path.extname(file.name) || ".png";
|
|
const uniqueName = `${randomUUID()}${ext}`;
|
|
const filePath = path.join(screenshotsDir, uniqueName);
|
|
|
|
const buffer = Buffer.from(await file.arrayBuffer());
|
|
await writeFile(filePath, buffer);
|
|
|
|
uploaded.push({
|
|
fileName: file.name,
|
|
path: `${relativeBase}/${uniqueName}`,
|
|
});
|
|
}
|
|
|
|
return Response.json({ uploaded });
|
|
}
|