Skip to content

Commit

Permalink
app routes room $roomName: add logs for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
cmnord committed Jul 12, 2024
1 parent 0191f5b commit 5b6d995
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/routes/room.$roomName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,31 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
const roomParts = roomName.split("-");
const roomId = parseInt(roomParts[0]);
const roomWord = roomParts[1];
console.log("getting room", roomId);
const room = await getRoom(roomId);
if (!room || room.name !== roomWord) {
throw new Response("room not found", { status: 404 });
}

console.log("getting valid auth session");
const authSession = await getValidAuthSession(request);
console.log("getting game", room.game_id);
const game = await getGame(room.game_id, authSession?.userId);
if (!game) {
throw new Response("game not found", { status: 404 });
}

console.log("getting user", authSession?.email);
const user = authSession
? await getUserByEmail(authSession.email, authSession.accessToken)
: null;
const accessToken = authSession?.accessToken;

console.log("getting room events for room", room.id);
const roomEvents = await getRoomEvents(room.id);
const name = getRandomEmoji();

console.log("applying", roomEvents.length, "room events to state");
const state = applyRoomEventsToState(stateFromGame(game), roomEvents);

if (state.type === GameState.GameOver) {
Expand Down

0 comments on commit 5b6d995

Please sign in to comment.