import { NextResponse } from 'next/server';

export const dynamic = 'force-dynamic';

const BACKEND_URL = process.env.BACKEND_URL || 'http://localhost:3000';

/**
 * Founder-seat count proxy (Truth-Everywhere Part 2, item 2) — forwards
 * GET /api/founders/count to Express (real active paying founders). On any
 * upstream failure we return { available: false } so the ClaimMeter HIDES —
 * never a fabricated number.
 */
export async function GET() {
  try {
    const upstream = await fetch(`${BACKEND_URL}/api/founders/count`, {
      method: 'GET',
      headers: { Accept: 'application/json' },
      cache: 'no-store',
    });
    const data = await upstream.json().catch(() => ({ available: false }));
    return NextResponse.json(data, { status: upstream.ok ? 200 : 200 });
  } catch {
    return NextResponse.json({ available: false }, { status: 200 });
  }
}
