mirror of
https://github.com/caty21/forex-dashboard.git
synced 2026-07-27 20:37:45 +00:00
17 lines
589 B
TypeScript
17 lines
589 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { readFileSync } from "fs";
|
|
import { join } from "path";
|
|
|
|
export async function GET() {
|
|
try {
|
|
const filePath = join(process.cwd(), "data", "rate_expectations.json");
|
|
const raw = readFileSync(filePath, "utf-8");
|
|
const data = JSON.parse(raw);
|
|
// Return the most recent snapshot (first item)
|
|
const latest = Array.isArray(data) ? data[0] : data;
|
|
return NextResponse.json(latest);
|
|
} catch {
|
|
return NextResponse.json({ error: "rate_expectations.json not found. Run the scraper first." }, { status: 404 });
|
|
}
|
|
}
|