import { requireSuperAdmin } from '../../../utils/auth'
import { getAllSiteConfigs } from '../../../database/queries/siteconfig'
import { handleApiError, createSuccessResponse } from '../../../utils/errors'

export default defineEventHandler(async (event) => {
  try {
    await requireSuperAdmin(event)

    const configs = await getAllSiteConfigs()

    return createSuccessResponse(configs, 'Site configs retrieved successfully')
  } catch (error) {
    throw handleApiError(error)
  }
})
