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

export default defineEventHandler(async (event) => {
  try {
    await requireSuperAdmin(event)
    const feedback = await getAllFeedback()
    return createSuccessResponse(feedback, 'Feedback retrieved successfully')
  } catch (error) {
    throw handleApiError(error)
  }
})
