feat: add getRoomInfo to jackbox-api for full room data including host

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-20 11:04:54 -04:00
parent 7712ebeb04
commit 0fc2ddbf23
2 changed files with 44 additions and 1 deletions

View File

@@ -39,4 +39,36 @@ async function checkRoomStatus(roomCode) {
}
}
module.exports = { checkRoomStatus };
async function getRoomInfo(roomCode) {
try {
const response = await fetch(`${JACKBOX_API_BASE}/rooms/${roomCode}`, {
headers: DEFAULT_HEADERS
});
if (!response.ok) {
return { exists: false };
}
const data = await response.json();
const body = data.body || data;
return {
exists: true,
host: body.host,
audienceHost: body.audienceHost,
appTag: body.appTag,
appId: body.appId,
code: body.code,
locked: body.locked || false,
full: body.full || false,
maxPlayers: body.maxPlayers || 8,
minPlayers: body.minPlayers || 0,
audienceEnabled: body.audienceEnabled || false,
};
} catch (e) {
console.error(`[Jackbox API] Error getting room info for ${roomCode}:`, e.message);
return { exists: false };
}
}
module.exports = { checkRoomStatus, getRoomInfo };

View File

@@ -0,0 +1,11 @@
const { getRoomInfo, checkRoomStatus } = require('../../backend/utils/jackbox-api');
describe('jackbox-api exports', () => {
test('getRoomInfo is exported as a function', () => {
expect(typeof getRoomInfo).toBe('function');
});
test('checkRoomStatus is still exported', () => {
expect(typeof checkRoomStatus).toBe('function');
});
});