From 83831ac03088d7d888e77b32f8d92f91c999ba62 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Tue, 28 Jul 2026 12:39:47 +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..f255495 --- /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 || '' + +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, { next: { revalidate: 60 } }) + 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: [] }) + } +}