Added logger and tests

This commit is contained in:
Emil
2026-02-24 10:02:13 +01:00
parent cfc4cb6849
commit 9b92883d30
16 changed files with 104 additions and 44 deletions
+5 -2
View File
@@ -1,5 +1,8 @@
import { createLogger } from '@/lib/logger'
import type { Currency, ExchangeRate } from '@/types'
const log = createLogger('riksbanken')
/**
* Fetch exchange rates from Riksbanken API
* Uses their public API for daily exchange rates
@@ -31,7 +34,7 @@ export async function fetchExchangeRate(
const seriesId = seriesIds[currency]
if (!seriesId) {
console.error(`Unknown currency: ${currency}`)
log.error(`Unknown currency: ${currency}`)
return null
}
@@ -84,7 +87,7 @@ export async function fetchExchangeRate(
return null
} catch (error) {
console.error('Error fetching exchange rate:', error)
log.error('Error fetching exchange rate:', error)
// Return fallback rates for development/testing
return getFallbackRate(currency)
}