fix: replace direct uuid import with IdGenerator in CreateServerForUser#280
Merged
sonikro merged 1 commit intoMay 16, 2026
Conversation
Closes #265 - Add idGenerator: IdGenerator to CreateServerForUser dependencies - Replace uuid() call with idGenerator.generate() - Remove direct uuid library import from core use case - Pass UuidIdGenerator instance in discordBot.ts wiring - Update test to mock IdGenerator instead of mocking uuid module Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Removes the direct uuid dependency from the CreateServerForUser core use case by introducing the existing IdGenerator interface via dependency injection, aligning it with the pattern already used in CreateServerForClient.
Changes:
- Inject
IdGeneratorintoCreateServerForUserand replaceuuid()withidGenerator.generate(). - Wire
UuidIdGeneratorin the Discord bot entrypoint. - Update the test suite to mock
IdGeneratorinstead ofvi.mock("uuid").
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/usecase/CreateServerForUser.ts | Add IdGenerator dependency, remove uuid import, use idGenerator.generate(). |
| packages/entrypoints/src/discordBot.ts | Pass new UuidIdGenerator() when constructing CreateServerForUser. |
| packages/core/src/usecase/CreateServerForUser.test.ts | Replace vi.mock("uuid") with a vitest-mock-extended mock of IdGenerator. |
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
Fixes #265
Changes
CreateServerForUser.ts: AddedidGenerator: IdGeneratorto the dependencies object, replaceduuid()call withidGenerator.generate(), and removed the directuuidlibrary importdiscordBot.ts: PassidGenerator: new UuidIdGenerator()when wiringCreateServerForUserCreateServerForUser.test.ts: Removedvi.mock("uuid")and replaced with a properIdGeneratormock viavitest-mock-extendedWhy
The core layer must not have direct external library dependencies. The
IdGeneratorinterface already exists inpackages/core/src/services/IdGenerator.tsfor this purpose, and the sibling use caseCreateServerForClientalready follows this pattern correctly.