import { handleApiError, createSuccessResponse } from '../../utils/errors'

export default defineEventHandler(async () => {
  try {
    const enabledProviders: string[] = []
    const socialProviders: AuthConfig['socialProviders'] = getAuthConfig().socialProviders

    if (socialProviders.github) {
      enabledProviders.push('github')
    }

    if (socialProviders.google) {
      enabledProviders.push('google')
    }

    return createSuccessResponse<{ providers: string[] }>({
      providers: enabledProviders
    })
  } catch (error) {
    throw handleApiError(error)
  }
})
