2024-03-31 04:18:41 +03:00
|
|
|
from fastapi import FastAPI
|
2024-04-01 12:19:10 +03:00
|
|
|
from sqlalchemy.ext.asyncio import (AsyncEngine, AsyncSession,
|
|
|
|
async_sessionmaker)
|
2024-03-31 04:18:41 +03:00
|
|
|
|
|
|
|
from api.application.abstractions.uow import UnitOfWork
|
2024-04-01 01:12:01 +03:00
|
|
|
from api.application.protocols.password_hasher import PasswordHasher
|
2024-04-01 12:19:10 +03:00
|
|
|
from api.application.usecase.auth.create_user import CreateUser
|
2024-03-31 04:18:41 +03:00
|
|
|
from api.domain.user.repository import UserRepository
|
2024-04-01 12:19:10 +03:00
|
|
|
from api.infrastructure.dependencies.adapters import (create_engine,
|
|
|
|
create_session_maker,
|
|
|
|
new_session,
|
|
|
|
new_unit_of_work)
|
2024-03-31 21:07:59 +03:00
|
|
|
from api.infrastructure.dependencies.configs import app_settings
|
2024-04-01 01:12:01 +03:00
|
|
|
from api.infrastructure.dependencies.protocols import get_password_hasher
|
2024-03-31 04:18:41 +03:00
|
|
|
from api.infrastructure.dependencies.repositories import get_user_repository
|
|
|
|
from api.infrastructure.dependencies.usecases import provide_create_user
|
2024-03-31 21:07:59 +03:00
|
|
|
from api.infrastructure.settings import Settings
|
2024-03-31 04:18:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
def init_dependencies(app: FastAPI) -> None:
|
2024-03-31 21:07:59 +03:00
|
|
|
app.dependency_overrides[Settings] = app_settings
|
2024-04-01 01:12:01 +03:00
|
|
|
|
2024-03-31 04:18:41 +03:00
|
|
|
app.dependency_overrides[AsyncEngine] = create_engine
|
|
|
|
app.dependency_overrides[async_sessionmaker[AsyncSession]] = create_session_maker
|
|
|
|
app.dependency_overrides[AsyncSession] = new_session
|
2024-04-01 01:12:01 +03:00
|
|
|
|
2024-03-31 04:18:41 +03:00
|
|
|
app.dependency_overrides[UnitOfWork] = new_unit_of_work
|
2024-04-01 01:12:01 +03:00
|
|
|
|
|
|
|
app.dependency_overrides[PasswordHasher] = get_password_hasher
|
|
|
|
|
|
|
|
app.dependency_overrides[UserRepository] = get_user_repository
|
|
|
|
|
2024-03-31 04:18:41 +03:00
|
|
|
app.dependency_overrides[CreateUser] = provide_create_user
|