mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
fix: currency converter and auth apis
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { getSession } from "@/lib/auth"
|
||||
import { PoorManCache } from "@/lib/cache"
|
||||
import { format } from "date-fns"
|
||||
import { format, isSameDay, subDays } from "date-fns"
|
||||
import { NextRequest, NextResponse } from "next/server"
|
||||
|
||||
type HistoricRate = {
|
||||
@@ -36,11 +36,17 @@ export async function GET(request: NextRequest) {
|
||||
return NextResponse.json({ error: "Missing required parameters: from, to, date" }, { status: 400 })
|
||||
}
|
||||
|
||||
const date = new Date(dateParam)
|
||||
let date = new Date(dateParam)
|
||||
|
||||
if (isNaN(date.getTime())) {
|
||||
return NextResponse.json({ error: "Invalid date format" }, { status: 400 })
|
||||
}
|
||||
|
||||
// hack to get yesterday's rate if it's today
|
||||
if (isSameDay(date, new Date())) {
|
||||
date = subDays(date, 1)
|
||||
}
|
||||
|
||||
const formattedDate = format(date, "yyyy-MM-dd")
|
||||
|
||||
// Check cache first
|
||||
|
||||
Reference in New Issue
Block a user