24 lines
1008 B
Python
24 lines
1008 B
Python
from fastapi import FastAPI
|
|
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker
|
|
|
|
from api.application.abstractions.uow import UnitOfWork
|
|
from api.application.usecase.create_user import CreateUser
|
|
from api.domain.user.repository import UserRepository
|
|
from api.infrastructure.dependencies.adapters import (
|
|
create_engine,
|
|
create_session_maker,
|
|
new_session,
|
|
new_unit_of_work,
|
|
)
|
|
from api.infrastructure.dependencies.repositories import get_user_repository
|
|
from api.infrastructure.dependencies.usecases import provide_create_user
|
|
|
|
|
|
def init_dependencies(app: FastAPI) -> None:
|
|
app.dependency_overrides[AsyncEngine] = create_engine
|
|
app.dependency_overrides[async_sessionmaker[AsyncSession]] = create_session_maker
|
|
app.dependency_overrides[AsyncSession] = new_session
|
|
app.dependency_overrides[UserRepository] = get_user_repository
|
|
app.dependency_overrides[UnitOfWork] = new_unit_of_work
|
|
app.dependency_overrides[CreateUser] = provide_create_user
|