19 lines
651 B
Python
19 lines
651 B
Python
"""
|
|
Application dependencies and providers
|
|
"""
|
|
from typing import AsyncGenerator
|
|
from fastapi import Depends
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.core.database import AsyncSessionLocal
|
|
from app.services.config_manager import ConfigManager
|
|
|
|
async def get_db_session() -> AsyncGenerator[AsyncSession, None]:
|
|
"""Provides a database session to the application."""
|
|
async with AsyncSessionLocal() as session:
|
|
yield session
|
|
|
|
def get_config_manager(db_session: AsyncSession = Depends(get_db_session)) -> ConfigManager:
|
|
"""Dependency to get the configuration manager."""
|
|
return ConfigManager(db_session=db_session)
|