Apply SOLID principles: repository layer, service action map, named constants#5
Open
Valamorde wants to merge 1 commit into
Open
Apply SOLID principles: repository layer, service action map, named constants#5Valamorde wants to merge 1 commit into
Valamorde wants to merge 1 commit into
Conversation
…ap, constants - Repository pattern: connection/scene/campaign repos encapsulate all DDB access; no handler imports DDB commands or keys directly - Services handler split into 7 action files under src/services/actions/ mirroring the sendmessage dispatch-map pattern (SRP + OCP) - Named constants: TTL_SECONDS, DEFAULT_SCENE_ID, BATCH_SIZE, SCENE_ORDER_SPACING - dmjoin: eliminate duplicated getCurrentSceneId helper via sceneRepo.getDmScene() - forward.ts: remove profanity log, use console.error for query failure - All 20 smoke tests pass; cdk synth unchanged
5779d1c to
f1c2687
Compare
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
src/repositories/): introducesconnectionRepo,sceneRepo, andcampaignRepo— plain objects that encapsulate all DynamoDB access patterns. Handlers no longer import DDB command types, key builders, or the table name directly.services/handler.tsbecomes aRecord<string, ServiceAction>map; each action moves to its own file undersrc/handlers/services/.src/shared/constants.ts): eliminates magic numbers scattered across the codebase (TTL_SECONDS = 7200,DEFAULT_SCENE_ID = '666',BATCH_SIZE = 25,SCENE_ORDER_SPACING = 1_000_000).VTTMessageintypes.ts— handlers receive narrowed types.console.log(event)insetCampaignData(was logging full requests including headers), replaces the profanity-laden error log inforward.tswithconsole.error, deduplicatesgetCurrentSceneIdlogic shared betweendmjoinandplayerjoin.Notes
No observable behavior changes. Existing tests pass without modification —
mockClient(DynamoDBDocumentClient)patches the shared singleton that all repositories use internally.Test plan
pnpm test— all tests pass@aws-sdk/lib-dynamodbdirectlykeys.tsdirectlyconsole.logwith raw event data in production handlers