Initial commit with 2026 World Cup Quant Platform core modules and CI/CD

This commit is contained in:
QuantBot
2026-06-13 23:18:18 +08:00
commit 073abf98c1
155 changed files with 19539 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import { NextRequest, NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function POST(req: NextRequest) {
try {
const body = await req.text();
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/backtest`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
});
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : '回測服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,21 @@
import { NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function GET(_: Request, { params }: { params: Promise<{ date: string }> }) {
try {
const { date } = await params;
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/daily-card/${date}`, { method: 'GET' });
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : '每日操盤卡服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,25 @@
import { NextRequest, NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function POST(req: NextRequest) {
try {
const body = await req.text();
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/hedging`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
});
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : '對沖計算服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,25 @@
import { NextRequest, NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function POST(req: NextRequest) {
try {
const body = await req.text();
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/kelly`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
});
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : '凱利計算服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,25 @@
import { NextRequest, NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function POST(req: NextRequest) {
try {
const body = await req.text();
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/match-conditions`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
});
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : '比賽條件分析服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,26 @@
import { NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function GET(_: Request, { params }: { params: Promise<{ matchId: string }> }) {
try {
const { matchId } = await params;
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/matches/${matchId}`, {
method: 'GET',
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : '賽事預測服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,25 @@
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/matches`, {
method: 'GET',
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : '賽事列表服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,26 @@
import { NextRequest, NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function POST(req: NextRequest) {
try {
const body = await req.text();
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/ml-edge`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
});
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : 'ML Edge 服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,25 @@
import { NextRequest, NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function POST(req: NextRequest) {
try {
const body = await req.text();
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/ml-edge/train`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
});
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : 'ML Edge 訓練服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,25 @@
import { NextRequest, NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function POST(req: NextRequest) {
try {
const body = await req.text();
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/player-props`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
});
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : '玩家道具盤分析服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,25 @@
import { NextRequest, NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function POST(req: NextRequest) {
try {
const body = await req.text();
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/portfolio/leaks`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
});
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : '投注漏財分析服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,23 @@
import { NextRequest, NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function GET(req: NextRequest) {
try {
const limit = req.nextUrl.searchParams.get('limit') || '200';
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/proof-of-yield/ledger?limit=${limit}`, {
method: 'GET',
});
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : '公開帳本服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,5 @@
import { NextResponse } from 'next/server';
export async function GET() {
return NextResponse.json({ message: '請使用 /api/analytics/proof-of-yield/ledger 或 /api/analytics/proof-of-yield/settle' }, { status: 404 });
}

View File

@@ -0,0 +1,25 @@
import { NextRequest, NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function POST(req: NextRequest) {
try {
const body = await req.text();
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/proof-of-yield/settle`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
});
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : '結算服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,25 @@
import { NextRequest, NextResponse } from 'next/server';
const ANALYTICS_BACKEND = process.env.ANALYTICS_BACKEND_URL || 'http://127.0.0.1:8000';
export async function POST(req: NextRequest) {
try {
const body = await req.text();
const response = await fetch(`${ANALYTICS_BACKEND}/analytics/rlm`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body,
});
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(data);
} catch (error) {
const message = error instanceof Error ? error.message : 'RLM 服務暫時無法連線';
return NextResponse.json({ message }, { status: 502 });
}
}

View File

@@ -0,0 +1,4 @@
import { handlers } from '@/lib/auth';
export const { GET, POST } = handlers;