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

[Dependency Injection] Add macro based DI #92

Merged
merged 11 commits into from
Dec 9, 2024
Merged

Conversation

joshuawright11
Copy link
Member

@joshuawright11 joshuawright11 commented Dec 8, 2024

Leverage macros to simplify DI.

extension Container {
    @Singleton var database: Database = isTest ? .memory : .postgres(...)
}

// access database, ensuring it's resolved once
Container.$database

// override the value, i.e. in a test
Container.$database = .stub(...)

// `@propertyWrapper` sugar
@Injected(\.$database) var database

Will drop the $ syntax when (if) this issue is fixed.

Also in this PR:

  • convert a decent chunk of tests to swift-testing
  • remove AlchemyC in favor of Bcrypt implementation from hummingbird-auth
  • restructure package structure

@joshuawright11 joshuawright11 merged commit 2e66ca2 into main Dec 9, 2024
2 checks passed
@joshuawright11 joshuawright11 deleted the swift-testing branch December 9, 2024 00:27
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