Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR standardizes code style (quotes, formatting), modularizes server routing into dedicated handlers, and expands KV store functionality with CRUD helpers and cleanup logic.
- Standardized imports and logging to single-quote style across stores and handlers
- Refactored
server.tsto use modular HTTP & WebSocket handlers and added REST endpoints (includingrejoinRoom) - Introduced KV utility modules (
kv.ts,kvCleanupJob.ts,clear_kv.ts) with accompanying tests for room and user token CRUD
Reviewed Changes
Copilot reviewed 51 out of 51 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| backend/store/memory/memorySocketStore.ts | Normalized import quotes and console.log quoting |
| backend/store/kv/kvSocketStore.ts | Consistent array literal key quoting and log formatting |
| backend/store/kv/kvRoomStore.ts | Refactored multiline type declaration and log formatting |
| backend/store/interfaces.ts | Switched to single-quote imports |
| backend/store/index.ts | Reformatted arrow function signatures and imports |
| backend/socketMessageHandler.ts | Consistent import quotes and semicolon/log formatting |
| backend/server.ts | Reworked routing: added HTTP handlers, debug view, new endpoints |
| backend/kv.ts | Added KV CRUD helpers for rooms and user tokens |
| backend/kvCleanupJob.ts | Implemented scheduled cleanup logic with tests |
| backend/clear_kv.ts | Utility to clear entire KV store |
| backend/kv_test.ts | Tests for KV CRUD operations |
| backend/handlers/wsHandlers.ts | New WebSocket connection & message handlers |
| backend/handlers/roomHandlers.ts | New HTTP room management handlers |
| backend/handlers/*_test.ts | Tests for WebSocket & room handlers |
| Procfile | Removed legacy Procfile entry |
| .github/ignore.copilot-instructions.md | Added contributor guidance |
Comments suppressed due to low confidence (4)
backend/kv.ts:90
- The key for deleting user_rooms is constructed as a single string
'user_rooms:${userToken}'instead of a structured array['user_rooms', userToken], which may break prefix-based queries and cleanup logic. Consider introducing auserRoomsKey(token)helper to mirrorroomKeyand useatomic.delete(['user_rooms', userToken]).
atomic.delete([`user_rooms:${userToken}`]);
backend/handlers/wsHandlers.ts:10
- [nitpick] Public exported functions like
handleWebSocketlack JSDoc comments. Consider adding a brief description of parameters, return value, and intended usage to improve maintainability.
export function handleWebSocket(
backend/kvCleanupJob.ts:71
- The cleanup logic for stale
socket_instancesisn’t covered by existing tests. Consider adding a test case that insertssocket_instanceswithout matchinguser_roomsand verifies they are deleted.
const socketEntries = kv.list({ prefix: ['socket_instances'] });
backend/store/kv/kvSocketStore.ts:48
- [nitpick] There are numerous
console.logstatements in production code. Consider introducing a configurable logger with levels to avoid cluttering stdout and to allow dynamic log filtering.
console.log('deleted socket: ', userToken);
| } else { | ||
| const atomic = kv.atomic() | ||
| atomic.delete(userTokenKey(body.userToken)) | ||
| atomic.delete([`user_rooms:${body.userToken}`]) |
There was a problem hiding this comment.
This deletion uses a colon-based composite key; for consistency with the rest of the KV schema, use ['user_rooms', body.userToken] or provide a helper function to generate this key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.