Skip to content

Remove container.ts (legacy DI) and adopt module-scoped factories #184

@Villarley

Description

@Villarley

🗂️ Issue: Remove container.ts (legacy DI) and adopt module-scoped factories

Description

There is a legacy container.ts (global DI container) that conflicts with the current modular architecture. Global containers hide dependencies, complicate tests, and break tree-shaking.

What is expected

  • Remove container.ts and any global container registrations.
  • Introduce module-scoped factories (simple functions) to compose controllers/use-cases/repositories explicitly.
  • Update imports at app bootstrap to use these factories.
  • Tests updated to instantiate modules without global side effects.

What should be modified

  • Delete container.ts and its references.
  • For each module, add a factory.ts (or similar) that wires repository → use-cases → controller(s).
  • Update routers to import controller handlers from the module factory.

Tests

  • Ensure unit/integration tests create module instances via factories (no global container).
  • Verify parallel test runs don’t share state.

Acceptance criteria

  • container.ts removed from the codebase.
  • All modules compose via local factories.
  • App boots and routes work as before.
  • Tests pass without global DI.

Rollback plan

  • Keep a branch/tag before removal.
  • If needed, temporarily keep a minimal shim that proxies to module factories while all imports are updated.

Metadata

Metadata

Assignees

Labels

onlydust-waveContribute to awesome OSS repos during OnlyDust's open source week

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions