Add GET /api/currencies/:date endpoint for historical EUR/DKK rates

Returns rates for a given date: today uses latest DB row, past dates
check DB first then fetch from Frankfurter and persist for caching.
Future dates and invalid formats return 400.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 12:36:22 +01:00
co-authored by Claude Opus 4.6
parent 11a1fc6b8f
commit e61f38d4f3
3 changed files with 84 additions and 10 deletions
+5 -1
View File
@@ -60,4 +60,8 @@ SET eur = EXCLUDED.eur, dkk = EXCLUDED.dkk, eur_dkk = EXCLUDED.eur_dkk, updated_
-- :name get-latest-currency-rates :? :1
-- :doc Get the most recent currency rates
SELECT eur, dkk, eur_dkk, updated_at FROM currencies ORDER BY rate_date DESC LIMIT 1
SELECT rate_date, eur, dkk, eur_dkk, updated_at FROM currencies ORDER BY rate_date DESC LIMIT 1
-- :name get-currency-rates-by-date :? :1
-- :doc Get currency rates for a specific date
SELECT rate_date, eur, dkk, eur_dkk, updated_at FROM currencies WHERE rate_date = :rate-date