Skip to content

Renew#30

Merged
ef81sp merged 44 commits intomainfrom
renew-backend
Jun 17, 2025
Merged

Renew#30
ef81sp merged 44 commits intomainfrom
renew-backend

Conversation

@ef81sp
Copy link
Copy Markdown
Owner

@ef81sp ef81sp commented Jun 17, 2025

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts to use modular HTTP & WebSocket handlers and added REST endpoints (including rejoinRoom)
  • 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 a userRoomsKey(token) helper to mirror roomKey and use atomic.delete(['user_rooms', userToken]).
atomic.delete([`user_rooms:${userToken}`]);

backend/handlers/wsHandlers.ts:10

  • [nitpick] Public exported functions like handleWebSocket lack 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_instances isn’t covered by existing tests. Consider adding a test case that inserts socket_instances without matching user_rooms and verifies they are deleted.
const socketEntries = kv.list({ prefix: ['socket_instances'] });

backend/store/kv/kvSocketStore.ts:48

  • [nitpick] There are numerous console.log statements 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);

Comment thread backend/handlers/roomHandlers.ts Outdated
} else {
const atomic = kv.atomic()
atomic.delete(userTokenKey(body.userToken))
atomic.delete([`user_rooms:${body.userToken}`])
Copy link

Copilot AI Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@ef81sp ef81sp merged commit ac8020b into main Jun 17, 2025
3 checks passed
@ef81sp ef81sp deleted the renew-backend branch June 17, 2025 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants