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>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { auth } from "@/lib/auth";
|
|
import { prisma } from "@/lib/prisma";
|
|
import { getActiveAppId } from "@/lib/active-app";
|
|
|
|
export async function GET(request: Request) {
|
|
const session = await auth();
|
|
if (!session) return new Response("Unauthorized", { status: 401 });
|
|
|
|
const { searchParams } = new URL(request.url);
|
|
const campaignId = searchParams.get("campaignId");
|
|
const type = searchParams.get("type");
|
|
const platform = searchParams.get("platform");
|
|
const status = searchParams.get("status");
|
|
const search = searchParams.get("search");
|
|
|
|
const appId = await getActiveAppId();
|
|
|
|
const where: Record<string, unknown> = {};
|
|
if (campaignId) where.campaignId = campaignId;
|
|
if (type && type !== "all") where.type = type;
|
|
if (platform && platform !== "all") where.platform = platform;
|
|
if (status && status !== "all") where.status = status;
|
|
if (search) {
|
|
where.OR = [
|
|
{ fileName: { contains: search } },
|
|
{ metadata: { contains: search } },
|
|
];
|
|
}
|
|
|
|
// Filter by active app's campaigns
|
|
if (appId) {
|
|
where.campaign = { ...((where.campaign as object) || {}), appId };
|
|
}
|
|
|
|
const assets = await prisma.asset.findMany({
|
|
where,
|
|
orderBy: { createdAt: "desc" },
|
|
include: { campaign: { select: { name: true } } },
|
|
});
|
|
|
|
return Response.json(assets);
|
|
}
|