From 2c7ea67185f37f114a33b02464ae3055e2228955 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Wed, 5 Aug 2026 18:14:40 +0000 Subject: [PATCH] Deploy --- src/app/api/content/[collection]/route.ts | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/app/api/content/[collection]/route.ts diff --git a/src/app/api/content/[collection]/route.ts b/src/app/api/content/[collection]/route.ts new file mode 100644 index 0000000..f97f652 --- /dev/null +++ b/src/app/api/content/[collection]/route.ts @@ -0,0 +1,24 @@ +import { NextRequest, NextResponse } from 'next/server' + +const VULA_CMS_URL = process.env.VULA_CMS_URL || 'https://ide.vulai.co.za' +const VULA_CMS_PROJECT_ID = process.env.VULA_CMS_PROJECT_ID || 'e9195bbc-f558-441e-b69d-2874af86ac58' + +export async function GET( + request: NextRequest, + { params }: { params: Promise<{ collection: string }> } +) { + const { collection } = await params + if (!VULA_CMS_PROJECT_ID) return NextResponse.json({ items: [] }) + try { + const { searchParams } = request.nextUrl + const status = searchParams.get('status') || 'published' + const limit = searchParams.get('limit') || '20' + const url = `${VULA_CMS_URL}/api/public/cms/${VULA_CMS_PROJECT_ID}/${collection}?status=${status}&limit=${limit}` + const res = await fetch(url, { cache: 'no-store' }) + if (!res.ok) return NextResponse.json({ items: [] }) + const json = await res.json() as { items?: unknown[] } + return NextResponse.json({ items: json.items ?? [] }) + } catch { + return NextResponse.json({ items: [] }) + } +}