/**
 * Get all Metabase cards/questions
 */
export default defineEventHandler(async (event) => {
  try {
    const query = getQuery(event)
    const filter = query.f as string | undefined

    const cards = await getMetabaseCards(filter)
    return cards
  } catch (error: any) {
    console.error('[API] Failed to get Metabase cards:', error)
    throw createError({
      statusCode: error.statusCode || 500,
      statusMessage: error.statusMessage || 'Failed to fetch cards'
    })
  }
})
