From 1e9b8a0d11479dabc5941dde722e530435386b4b Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Fri, 6 Mar 2026 11:49:56 +0800 Subject: [PATCH] feat: Implement new Next.js frontend with an embedded Leaflet map dashboard, city markers, and Polymarket API integration. --- frontend/app/api/polymarket/[name]/route.ts | 53 +++++++++++++++++++++ frontend/app/page.tsx | 2 +- frontend/public/legacy/index.html | 8 ++++ frontend/public/static/app.js | 24 +++++----- web/static/app.js | 24 +++++----- 5 files changed, 86 insertions(+), 25 deletions(-) create mode 100644 frontend/app/api/polymarket/[name]/route.ts diff --git a/frontend/app/api/polymarket/[name]/route.ts b/frontend/app/api/polymarket/[name]/route.ts new file mode 100644 index 00000000..63b24928 --- /dev/null +++ b/frontend/app/api/polymarket/[name]/route.ts @@ -0,0 +1,53 @@ +import { NextRequest, NextResponse } from "next/server"; + +const API_BASE = process.env.POLYWEATHER_API_BASE_URL; + +export async function GET( + req: NextRequest, + context: { params: Promise<{ name: string }> }, +) { + if (!API_BASE) { + return NextResponse.json( + { error: "POLYWEATHER_API_BASE_URL is not configured" }, + { status: 500 }, + ); + } + + const { name } = await context.params; + const params = new URLSearchParams(); + const forceRefresh = req.nextUrl.searchParams.get("force_refresh"); + const targetDate = req.nextUrl.searchParams.get("target_date"); + + if (forceRefresh != null) { + params.set("force_refresh", forceRefresh); + } + if (targetDate) { + params.set("target_date", targetDate); + } + + const qs = params.toString(); + const url = `${API_BASE}/api/polymarket/${encodeURIComponent(name)}${qs ? `?${qs}` : ""}`; + + try { + const res = await fetch(url, { + headers: { Accept: "application/json" }, + cache: "no-store", + }); + + if (!res.ok) { + const raw = await res.text(); + return NextResponse.json( + { error: `Backend returned ${res.status}`, detail: raw.slice(0, 300) }, + { status: 502 }, + ); + } + + const data = await res.json(); + return NextResponse.json(data); + } catch (error) { + return NextResponse.json( + { error: "Failed to fetch polymarket snapshot", detail: String(error) }, + { status: 500 }, + ); + } +} diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index 19446599..852e2630 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -3,7 +3,7 @@ export default function HomePage() {