/**
 * Execute a Metabase card query with cache (GET)
 */
export default defineEventHandler(async (event) => {
  try {
    const id = getRouterParam(event, 'id')

    if (!id) {
      throw createError({
        statusCode: 400,
        statusMessage: 'Card ID is required'
      })
    }

    const result = await executeCardQueryCached(parseInt(id))
    return result
  } catch (error: any) {
    console.error('[API] Failed to execute cached query:', error)
    throw createError({
      statusCode: error.statusCode || 500,
      statusMessage: error.statusMessage || 'Failed to execute cached query'
    })
  }
})
