refactor(api): switch nowScores endpoint from GET query to POST JSON body

- send uids as JSON payload in frontend event loader
- update /api/user/nowScores route to accept POST and parse req.json()
- keep score lookup behavior unchanged
This commit is contained in:
kyuuseiryuu 2026-03-03 00:58:58 +09:00
parent 1fae8206f2
commit 9e892f6ed1
2 changed files with 7 additions and 4 deletions

View File

@ -48,7 +48,11 @@ const route = createBrowserRouter([
score: e.score, score: e.score,
realname: e.name, realname: e.name,
} as XCXMember)); } as XCXMember));
const uidScore = await fetch(`/api/user/nowScores?uids=${info.players.map(e => e.uid).join(',')}`); const uids = info.players.map(e => e.uid);
const uidScore = await fetch(`/api/user/nowScores`, {
method: "POST",
body: JSON.stringify({ uids }),
});
return { info, members, uidScore: new Map(Object.entries(await uidScore.json())) }; return { info, members, uidScore: new Map(Object.entries(await uidScore.json())) };
}, },
Component: EventPage, Component: EventPage,

View File

@ -43,9 +43,8 @@ const server = serve({
} }
}, },
"/api/user/nowScores": { "/api/user/nowScores": {
async GET(req) { async POST(req) {
const searchParams = new URL(req.url).searchParams; const { uids } = await req.json();
const uids = searchParams.get('uids')?.split(',') ?? [];
const uidScore = await getUidScore(uids); const uidScore = await getUidScore(uids);
return Response.json(uidScore); return Response.json(uidScore);
} }