2024-03-31 04:18:41 +03:00
|
|
|
from fastapi import FastAPI
|
2024-04-23 12:08:56 +03:00
|
|
|
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker
|
2024-03-31 04:18:41 +03:00
|
|
|
|
2024-04-23 11:10:17 +03:00
|
|
|
from api.application.abstractions.transaction import TransactionContextManager
|
2024-04-02 22:33:15 +03:00
|
|
|
from api.application.protocols.date_time import DateTimeProvider
|
2024-04-04 13:51:51 +03:00
|
|
|
from api.application.protocols.jwt import JwtTokenProcessor
|
2024-04-01 01:12:01 +03:00
|
|
|
from api.application.protocols.password_hasher import PasswordHasher
|
2024-04-04 13:51:51 +03:00
|
|
|
from api.application.usecase.auth.auth_user import LoginUser
|
2024-04-01 12:19:10 +03:00
|
|
|
from api.application.usecase.auth.create_user import CreateUser
|
2024-04-21 23:46:17 +03:00
|
|
|
from api.application.usecase.company.create_company import CreateCompany
|
2024-04-23 12:08:56 +03:00
|
|
|
from api.application.usecase.company.get_users_company import GetCompaniesByOwnerEmail
|
2024-04-10 00:33:31 +03:00
|
|
|
from api.domain.company.repository import CompanyRepository
|
2024-03-31 04:18:41 +03:00
|
|
|
from api.domain.user.repository import UserRepository
|
2024-04-08 00:31:15 +03:00
|
|
|
from api.infrastructure.auth.jwt_settings import JwtSettings
|
2024-04-23 12:08:56 +03:00
|
|
|
from api.infrastructure.dependencies.adapters import (
|
|
|
|
create_engine,
|
|
|
|
create_session_maker,
|
|
|
|
get_transaction_context,
|
|
|
|
new_session,
|
|
|
|
)
|
|
|
|
from api.infrastructure.dependencies.configs import (
|
|
|
|
app_settings,
|
|
|
|
get_db_settings,
|
|
|
|
get_jwt_settings,
|
|
|
|
)
|
|
|
|
from api.infrastructure.dependencies.protocols import (
|
|
|
|
get_date_time_provider,
|
|
|
|
get_jwt_token_processor,
|
|
|
|
get_password_hasher,
|
|
|
|
get_user_login,
|
|
|
|
)
|
2024-04-10 00:33:31 +03:00
|
|
|
from api.infrastructure.dependencies.repositories import (
|
2024-04-23 12:08:56 +03:00
|
|
|
get_company_repository,
|
|
|
|
get_user_repository,
|
|
|
|
)
|
2024-04-10 00:33:31 +03:00
|
|
|
from api.infrastructure.dependencies.usecases import (
|
2024-04-23 12:08:56 +03:00
|
|
|
provide_create_company,
|
|
|
|
provide_create_user,
|
|
|
|
provide_get_companies_by_email,
|
|
|
|
)
|
2024-04-08 00:31:15 +03:00
|
|
|
from api.infrastructure.persistence.db_setings import DBSettings
|
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-04-08 00:31:15 +03:00
|
|
|
app.dependency_overrides[DBSettings] = get_db_settings
|
|
|
|
app.dependency_overrides[JwtSettings] = get_jwt_settings
|
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-04-23 11:10:17 +03:00
|
|
|
app.dependency_overrides[TransactionContextManager] = get_transaction_context
|
2024-04-01 01:12:01 +03:00
|
|
|
|
2024-04-02 22:33:15 +03:00
|
|
|
app.dependency_overrides[DateTimeProvider] = get_date_time_provider
|
2024-04-01 01:12:01 +03:00
|
|
|
app.dependency_overrides[PasswordHasher] = get_password_hasher
|
|
|
|
|
2024-04-04 13:51:51 +03:00
|
|
|
app.dependency_overrides[JwtTokenProcessor] = get_jwt_token_processor
|
|
|
|
app.dependency_overrides[LoginUser] = get_user_login
|
|
|
|
|
2024-04-01 01:12:01 +03:00
|
|
|
app.dependency_overrides[UserRepository] = get_user_repository
|
2024-04-10 00:33:31 +03:00
|
|
|
app.dependency_overrides[CompanyRepository] = get_company_repository
|
2024-04-01 01:12:01 +03:00
|
|
|
|
2024-03-31 04:18:41 +03:00
|
|
|
app.dependency_overrides[CreateUser] = provide_create_user
|
2024-04-10 00:33:31 +03:00
|
|
|
app.dependency_overrides[GetCompaniesByOwnerEmail] = provide_get_companies_by_email
|
2024-04-21 23:46:17 +03:00
|
|
|
app.dependency_overrides[CreateCompany] = provide_create_company
|