Files
2026FIFAWorldCup/platform/web/app/api/analytics/gemini-usage/route.ts
QuantBot 64cae96d0d
Some checks failed
2026 World Cup Quant Platform - Production Deployment / Code Quality, Security Gate & Testing (push) Failing after 4m12s
2026 World Cup Quant Platform - Production Deployment / Deploy to Production VM via Gitea CD (push) Has been skipped
deploy: push latest version to production
2026-06-26 14:06:37 +08:00

25 lines
854 B
TypeScript

import { NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function GET() {
try {
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/gemini-usage`, {
method: 'GET',
cache: 'no-store',
headers: { 'Content-Type': 'application/json' },
});
if (!response.ok) {
const message = await response.text();
return NextResponse.json({ message }, { status: response.status });
}
const data = (await response.json()) as Record<string, unknown>;
return NextResponse.json({ generated_at: new Date().toISOString(), ...data });
} catch (error) {
const message = error instanceof Error ? error.message : 'Gemini 用量服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}