feature: Implement Game Sessions backend module - #630
Merged
phertyameen merged 1 commit intoAug 19, 2026
Conversation
- GameSession entity with all required fields (userId, guestId, status, difficulty, selectedCategories, challengeCount, currentChallenge, score, xpEarned, startedAt, completedAt) - GameSessionStatus enum: CREATED, ACTIVE, PAUSED, COMPLETED, EXPIRED, ABANDONED - Full state machine with SESSION_TRANSITIONS map and terminal-state guard - GameSessionsService: create, findAllByUser, findActiveSession, findById, findAndVerifyOwnership, updateStatus, completeSession, expireIdleSessions - GameSessionsController: POST /, GET /, GET /active, GET /:id, PATCH /:id/status - DTOs with class-validator + Swagger decorators - 26 unit tests covering state machine, CRUD, ownership, and expiry logic closes MindBlockLabs#611
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
Author
|
Can you please approve vercel deployment? |
7 tasks
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.
Summary
Implements the
game-sessionsNestJS module as specified in #611.closes #611
What's included
Entity
GameSessionTypeORM entity with all fields from the spec:userId,guestId,status,difficulty,selectedCategories,challengeCount,currentChallenge,score,xpEarned,startedAt,completedAt.State machine
GameSessionStatusenum:CREATED,ACTIVE,PAUSED,COMPLETED,EXPIRED,ABANDONED.SESSION_TRANSITIONSmap enforces valid transitions; terminal-state guard prevents mutations afterCOMPLETED / EXPIRED / ABANDONED.Service (
GameSessionsService)create()– session creation for authenticated users and guests.findAllByUser()– list all sessions for a user.findActiveSession()– retrieve the single active session.findById()– 404-safe retrieval.findAndVerifyOwnership()– ownership enforcement (403 for non-owners).updateStatus()– validated state transitions with side-effects (stampstartedAt,completedAt, persistscore/xpEarned).completeSession()– convenience wrapper for marking COMPLETED.expireIdleSessions()– bulk-expire stale sessions (for scheduled jobs).Controller (
GameSessionsController)POST/game-sessionsGET/game-sessionsGET/game-sessions/activeGET/game-sessions/:idPATCH/game-sessions/:id/statusDTOs
CreateGameSessionDto– withclass-validatorand Swagger decorators.UpdateGameSessionStatusDto– with optional score/xpEarned for completion.GameSessionResponseDto– full Swagger-documented response shape.Module
GameSessionsModuleregistered inAppModule.Testing
26 unit tests covering:
expireIdleSessionsbulk expiry