import { NextResponse } from 'next/server';
import { getAdminDb } from '@/lib/firebase/admin';

export async function GET() {
  try {
    const adminDb = getAdminDb();
    const snapshot = await adminDb.collection('projects').limit(1).get();

    if (snapshot.empty) {
      return NextResponse.json(
        { error: 'No projects found' },
        { status: 404 },
      );
    }

    const doc = snapshot.docs[0];
    return NextResponse.json({
      id: doc.id,
      data: doc.data(),
    });
  } catch (error) {
    console.error('[debug/first-project] Failed to load project', error);
    return NextResponse.json(
      {
        error: 'Failed to load project',
        details: error instanceof Error ? error.message : String(error),
      },
      { status: 500 },
    );
  }
}


