add new content end game
All checks were successful
Gitea Auto Deploy / Deploy-Container (push) Successful in 2m2s
All checks were successful
Gitea Auto Deploy / Deploy-Container (push) Successful in 2m2s
This commit is contained in:
18
src/app/api/[locale]/peak/[id]/route.ts
Normal file
18
src/app/api/[locale]/peak/[id]/route.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { loadPeak } from '@/lib/loader'
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string, locale: string }> }
|
||||
) {
|
||||
|
||||
const { id, locale } = await params
|
||||
const peakData = await loadPeak([id], locale)
|
||||
const peak = peakData[id]
|
||||
|
||||
if (!peak) {
|
||||
return NextResponse.json({ error: 'Peak info not found' }, { status: 404 })
|
||||
}
|
||||
|
||||
return NextResponse.json(peak)
|
||||
}
|
||||
20
src/app/api/[locale]/peak/route.ts
Normal file
20
src/app/api/[locale]/peak/route.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { loadPeak } from "@/lib/loader";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const peakIds = body.peakIds as string[];
|
||||
const { locale } = await params;
|
||||
|
||||
if (!Array.isArray(peakIds) || peakIds.some(id => typeof id !== 'string')) {
|
||||
return NextResponse.json({ error: 'Invalid peakIds' }, { status: 400 });
|
||||
}
|
||||
|
||||
const peakData = await loadPeak(peakIds, locale);
|
||||
|
||||
return NextResponse.json(peakData);
|
||||
} catch {
|
||||
return NextResponse.json({ error: 'Failed to load peak data' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user