Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Dependency Injection instead of exporting instances from app entrypoint #399

Merged
merged 6 commits into from
Oct 15, 2024

Conversation

pablomendezroyo
Copy link
Contributor

@pablomendezroyo pablomendezroyo commented Oct 14, 2024

For large Node.js projects, the dependency injection approach (passing instances as parameters) is generally the better choice because:

  • It promotes testability and allows for easy mocking during unit tests.
  • It enhances maintainability and scalability, as the components are loosely coupled.
  • It provides greater flexibility when refactoring or evolving your application’s architecture.

To achieve this code structure this PR aims to remove all the exports of instances in the app entrypoint (index.ts) and pass them as parameters instead.

  • Remove exports from entrypoint
  • Inject instances as parameters
  • Group large list of parameters into interfaces for better redability

@pablomendezroyo pablomendezroyo requested a review from a team as a code owner October 14, 2024 16:10
@pablomendezroyo pablomendezroyo marked this pull request as draft October 14, 2024 16:11
@pablomendezroyo pablomendezroyo marked this pull request as ready for review October 15, 2024 14:02
@pablomendezroyo pablomendezroyo changed the title [WIP] Use Dependency Injection instead of exporting instances from app entrypoint Use Dependency Injection instead of exporting instances from app entrypoint Oct 15, 2024
@pablomendezroyo pablomendezroyo merged commit 9504305 into main Oct 15, 2024
2 checks passed
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.

1 participant