Add settings and history archive repository protocols and DI support
This commit is contained in:
@@ -26,7 +26,9 @@ from app.repositories.protocols import (
|
||||
BlocklistRepository,
|
||||
Fail2BanDbRepository,
|
||||
GeoCacheRepository,
|
||||
HistoryArchiveRepository,
|
||||
ImportLogRepository,
|
||||
SettingsRepository,
|
||||
SessionRepository,
|
||||
)
|
||||
from app.utils.constants import SESSION_COOKIE_NAME
|
||||
@@ -251,6 +253,20 @@ async def get_import_log_repo() -> ImportLogRepository:
|
||||
return cast("ImportLogRepository", import_log_repo)
|
||||
|
||||
|
||||
async def get_settings_repo() -> SettingsRepository:
|
||||
"""Provide the concrete settings repository implementation."""
|
||||
from app.repositories import settings_repo # noqa: PLC0415
|
||||
|
||||
return cast("SettingsRepository", settings_repo)
|
||||
|
||||
|
||||
async def get_history_archive_repo() -> HistoryArchiveRepository:
|
||||
"""Provide the concrete history archive repository implementation."""
|
||||
from app.repositories import history_archive_repo # noqa: PLC0415
|
||||
|
||||
return cast("HistoryArchiveRepository", history_archive_repo)
|
||||
|
||||
|
||||
async def get_geo_cache_repo() -> GeoCacheRepository:
|
||||
"""Provide the concrete geo cache repository implementation."""
|
||||
from app.repositories import geo_cache_repo # noqa: PLC0415
|
||||
@@ -370,6 +386,8 @@ ServerStatusDep = Annotated[ServerStatus, Depends(get_server_status)]
|
||||
PendingRecoveryDep = Annotated[PendingRecovery | None, Depends(get_pending_recovery)]
|
||||
SessionCacheDep = Annotated[SessionCache, Depends(get_session_cache)]
|
||||
SessionRepoDep = Annotated[SessionRepository, Depends(get_session_repo)]
|
||||
SettingsRepoDep = Annotated[SettingsRepository, Depends(get_settings_repo)]
|
||||
HistoryArchiveRepositoryDep = Annotated[HistoryArchiveRepository, Depends(get_history_archive_repo)]
|
||||
BlocklistRepositoryDep = Annotated[BlocklistRepository, Depends(get_blocklist_repo)]
|
||||
ImportLogRepositoryDep = Annotated[ImportLogRepository, Depends(get_import_log_repo)]
|
||||
GeoCacheRepositoryDep = Annotated[GeoCacheRepository, Depends(get_geo_cache_repo)]
|
||||
|
||||
Reference in New Issue
Block a user