import { NextResponse } from 'next/server';

import { withAuth } from '@/lib/api/helpers';
import { env } from '@/lib/env';

/**
 * GET /api/v1/internal/dev-flags
 *
 * Read-only feed of dev-mode safety flags that the UI surfaces as
 * always-visible badges. Authenticated (any signed-in user) - these
 * flags affect every outbound email so reps need to see them too,
 * not just admins.
 *
 * Today returns just `emailRedirectTo`. Add more flags here (e.g.
 * MOCK_DOCUMENSO, FAKE_PAYMENTS, READ_ONLY_DB) as they appear.
 */
export const GET = withAuth(async () => {
  return NextResponse.json({
    data: {
      emailRedirectTo: env.EMAIL_REDIRECT_TO ?? null,
      isDev: env.NODE_ENV !== 'production',
    },
  });
});
