export default defineEventHandler(async (event) => {
  const code = getRouterParam(event, 'code') ?? ''
  const rate = await getRateByCode(code)

  if (!rate) {
    throw createError({ statusCode: 404, statusMessage: 'Country not found', data: { error: 'Country not found' } })
  }

  setHeader(event, 'Cache-Control', 'public, max-age=3600')
  return rate
})
