Skip to content

fix: replace direct uuid import with IdGenerator in CreateServerForUser#280

Merged
sonikro merged 1 commit into
mainfrom
fix/265-replace-uuid-with-id-generator-in-create-server-for-user
May 16, 2026
Merged

fix: replace direct uuid import with IdGenerator in CreateServerForUser#280
sonikro merged 1 commit into
mainfrom
fix/265-replace-uuid-with-id-generator-in-create-server-for-user

Conversation

@sonikro
Copy link
Copy Markdown
Owner

@sonikro sonikro commented May 16, 2026

Summary

Fixes #265

Changes

  • CreateServerForUser.ts: Added idGenerator: IdGenerator to the dependencies object, replaced uuid() call with idGenerator.generate(), and removed the direct uuid library import
  • discordBot.ts: Pass idGenerator: new UuidIdGenerator() when wiring CreateServerForUser
  • CreateServerForUser.test.ts: Removed vi.mock("uuid") and replaced with a proper IdGenerator mock via vitest-mock-extended

Why

The core layer must not have direct external library dependencies. The IdGenerator interface already exists in packages/core/src/services/IdGenerator.ts for this purpose, and the sibling use case CreateServerForClient already follows this pattern correctly.

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>
Copilot AI review requested due to automatic review settings May 16, 2026 15:01
@sonikro sonikro enabled auto-merge (rebase) May 16, 2026 15:02
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

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 IdGenerator into CreateServerForUser and replace uuid() with idGenerator.generate().
  • Wire UuidIdGenerator in the Discord bot entrypoint.
  • Update the test suite to mock IdGenerator instead of vi.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.

@sonikro sonikro merged commit 46b897a into main May 16, 2026
13 checks passed
@sonikro sonikro deleted the fix/265-replace-uuid-with-id-generator-in-create-server-for-user branch May 16, 2026 15:10
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.

[Tech Debt] Replace direct uuid import with IdGenerator interface in CreateServerForUser

2 participants