Centralise DbDep and mark Task 11 complete

This commit is contained in:
2026-04-17 15:44:13 +02:00
parent 74ff4cb4b8
commit 7d16391c6c
3 changed files with 9 additions and 13 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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.