import { NextRequest, NextResponse } from 'next/server'; // Alpha: In-memory sponsor storage const sponsors: Map = new Map(); export async function GET() { const allSponsors = Array.from(sponsors.values()); return NextResponse.json({ sponsors: allSponsors }); } export async function POST(request: NextRequest) { try { const body = await request.json(); const { name, contactEmail, websiteUrl, logoUrl } = body; if (!name || !contactEmail) { return NextResponse.json( { error: 'Name and contact email are required' }, { status: 400 } ); } const id = `sponsor-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`; const sponsor = { id, name, contactEmail, websiteUrl: websiteUrl || undefined, logoUrl: logoUrl || undefined, createdAt: new Date(), }; sponsors.set(id, sponsor); return NextResponse.json({ sponsor }, { status: 201 }); } catch (err) { console.error('Sponsor creation failed:', err); return NextResponse.json( { error: 'Failed to create sponsor' }, { status: 500 } ); } }