Added logger and tests
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user