import { NextResponse } from 'next/server';
import { withErrorHandler } from '@server/middleware/withErrorHandler';
import { withAuth, requireSection, AuthedRequest } from '@server/middleware/withAuth';
import { getProvidersForUI } from '@server/services/ai-providers.service';

export const GET = withErrorHandler(
  withAuth(async (req: AuthedRequest) => {
    await requireSection(req, 'ai_config');
    const providers = await getProvidersForUI();
    return NextResponse.json({ providers });
  })
);
