import { NextResponse } from 'next/server';

import { hasAnySuperAdmin } from '@/lib/services/bootstrap.service';
import { errorResponse } from '@/lib/errors';

/**
 * GET /api/v1/bootstrap/status
 *
 * PUBLIC - no auth required. Used by the /setup and /login pages to
 * decide which screen to show on first visit. Returns only a single
 * boolean to keep the response small and minimize info leakage.
 */
export async function GET() {
  try {
    const initialized = await hasAnySuperAdmin();
    return NextResponse.json({ data: { needsBootstrap: !initialized } });
  } catch (error) {
    return errorResponse(error);
  }
}
