fix(api): include members and memberPlayers in room creation response

The client expects the POST /api/arcade/rooms response to include
members and memberPlayers fields, but the API was only returning
room and joinUrl. This caused room creation to fail on the client.

Fixes the "failed to create room" error on production.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-10-14 10:13:37 -05:00
parent a4251e660d
commit 8320d9e730

View File

@@ -135,6 +135,16 @@ export async function POST(req: NextRequest) {
isCreator: true,
})
// Get members and active players for the response
const members = await getRoomMembers(room.id)
const memberPlayers = await getRoomActivePlayers(room.id)
// Convert Map to object for JSON serialization
const memberPlayersObj: Record<string, any[]> = {}
for (const [uid, players] of memberPlayers.entries()) {
memberPlayersObj[uid] = players
}
// Generate join URL
const baseUrl = process.env.NEXT_PUBLIC_URL || 'http://localhost:3000'
const joinUrl = `${baseUrl}/arcade/rooms/${room.id}`
@@ -142,6 +152,8 @@ export async function POST(req: NextRequest) {
return NextResponse.json(
{
room,
members,
memberPlayers: memberPlayersObj,
joinUrl,
},
{ status: 201 }