import { NextResponse } from 'next/server'; import { getCustomerUser } from '@/app/lib/lumen-auth'; import { isAdmin } from '@/app/lib/admin'; import { listBoards } from '@/app/lib/pinterest'; export const runtime = 'nodejs'; export const dynamic = 'force-dynamic'; // Admin-gated. Returns the studio's Pinterest boards. Used by the CdnBrowser // pin modal to populate the board dropdown. export async function GET() { const user = await getCustomerUser(); if (!user || !isAdmin(user.email)) { return NextResponse.json({ error: 'forbidden' }, { status: 403 }); } try { const boards = await listBoards(); return NextResponse.json({ boards }); } catch (e) { const msg = e instanceof Error ? e.message : 'list-boards failed'; return NextResponse.json({ error: msg }, { status: 502 }); } }