import { NextResponse } from "next/server"; import fs from "fs"; import path from "path"; import { Team } from "@/lib/types"; export async function GET() { try { const filePath = path.join(process.cwd(), "data", "teams.json"); if (!fs.existsSync(filePath)) { return NextResponse.json({ teams: [] }); } const fileContent = fs.readFileSync(filePath, "utf-8"); const data = JSON.parse(fileContent); return NextResponse.json(data.teams as Team[]); } catch (error) { console.error("Error loading teams:", error); return NextResponse.json( { error: "Failed to load teams" }, { status: 500 } ); } }