diff --git a/Docs/Tasks.md b/Docs/Tasks.md index dd344ab..f7d5345 100644 --- a/Docs/Tasks.md +++ b/Docs/Tasks.md @@ -214,6 +214,8 @@ Reference: `Docs/Refactoring.md` for full analysis of each issue. **Why this is needed:** A single definition of `DbDep` ensures that any future change to the db dependency (e.g. adding row factory configuration) is applied uniformly across all routers. +**Status:** Completed ✅ + --- ### Task 12 — Complete the protocol injection layer or remove it diff --git a/backend/app/routers/blocklist.py b/backend/app/routers/blocklist.py index f9340b3..77080d3 100644 --- a/backend/app/routers/blocklist.py +++ b/backend/app/routers/blocklist.py @@ -22,19 +22,16 @@ registered *before* the ``/{id}`` routes so FastAPI resolves them correctly. from __future__ import annotations -from typing import Annotated - -import aiosqlite -from fastapi import APIRouter, Depends, HTTPException, Query, status +from fastapi import APIRouter, HTTPException, Query, status from app.dependencies import ( AuthDep, + DbDep, Fail2BanSocketDep, GeoBatchLookupDep, HttpSessionDep, SchedulerDep, SettingsDep, - get_db, ) from app.models.blocklist import ( BlocklistListResponse, @@ -52,8 +49,6 @@ from app.tasks.blocklist_import import run_import_with_resources router: APIRouter = APIRouter(prefix="/api/blocklists", tags=["Blocklists"]) -DbDep = Annotated[aiosqlite.Connection, Depends(get_db)] - # --------------------------------------------------------------------------- # Source list + create diff --git a/backend/app/routers/geo.py b/backend/app/routers/geo.py index d59311c..59cedd6 100644 --- a/backend/app/routers/geo.py +++ b/backend/app/routers/geo.py @@ -13,18 +13,17 @@ from typing import TYPE_CHECKING, Annotated if TYPE_CHECKING: from app.services.jail_service import IpLookupResult -import aiosqlite -from fastapi import APIRouter, Depends, HTTPException, Path, status +from fastapi import APIRouter, HTTPException, Path, status from app.dependencies import ( AuthDep, + DbDep, Fail2BanSocketDep, HttpSessionDep, - get_db, ) +from app.exceptions import Fail2BanConnectionError from app.models.geo import GeoCacheStatsResponse, GeoReResolveResponse, IpLookupResponse from app.services import geo_service, jail_service -from app.exceptions import Fail2BanConnectionError router: APIRouter = APIRouter(prefix="/api/geo", tags=["Geo"]) @@ -99,7 +98,7 @@ async def lookup_ip( ) async def geo_stats( _auth: AuthDep, - db: Annotated[aiosqlite.Connection, Depends(get_db)], + db: DbDep, ) -> GeoCacheStatsResponse: """Return diagnostic counters for the geo cache subsystem. @@ -123,7 +122,7 @@ async def geo_stats( ) async def re_resolve_geo( _auth: AuthDep, - db: Annotated[aiosqlite.Connection, Depends(get_db)], + db: DbDep, http_session: HttpSessionDep, ) -> GeoReResolveResponse: """Retry geo resolution for every IP in ``geo_cache`` with a null country.