feat: init
This commit is contained in:
11
server/api/v1/rates/[code].get.ts
Normal file
11
server/api/v1/rates/[code].get.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
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
|
||||
})
|
||||
5
server/api/v1/rates/index.get.ts
Normal file
5
server/api/v1/rates/index.get.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const rates = await getAllRates()
|
||||
setHeader(event, 'Cache-Control', 'public, max-age=3600')
|
||||
return rates
|
||||
})
|
||||
Reference in New Issue
Block a user