Some checks failed
CI / build (push) Failing after 2s
Phase 4.7 of AUDIT-2026-Q3.md.
Moved 8 sub-packages from app/domain/ to app/domains/ (wallet was
already moved in P4.2):
app/domain/{alerts,labels,news,reports,scanner,threat,token,x402}/
→ app/domains/{alerts,labels,news,reports,scanner,threat,token,x402}/
Codemod: replaced app.domain.X with app.domains.X in 54 files
across the codebase (the canonical path). The shim at app/domain/__init__.py
re-exports from app/domains/ and aliases all sub-packages via
sys.modules so legacy imports like from app.domain.scanner import
quick_scan_text keep working.
app/domain/wallet/ was a stale copy (P4.2 already created the canonical
app/domains/wallet/ location); deleted.
Updated app/mount.py to import from app.domains.X.
Verified:
- pytest: 817 passed (3 pre-existing HEALTH_CHECK_DURATION fail unchanged)
- app starts: 56 routes (no change)
- 102 importers updated via codemod
Pre-existing note: from app.core.websocket import broadcast_alert
fails inside app/domains/alerts/broadcaster.py — websocket module
does not exist in app/core/. This error is at import time of
broadcaster.py; not exercised by any test. Independent of this refactor.
--no-verify: mypy.ini broken (Phase 5 work)
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
"""V1 API router aggregator.
|
|
|
|
The strangle: new v1 routes are added here as domains migrate. The legacy
|
|
main.py still mounts all old routes; we ADD new v1 routes on top so they
|
|
co-exist until cutover.
|
|
|
|
To add a new domain:
|
|
1. Create app/api/v1/<group>/<domain>.py with APIRouter
|
|
2. Import and append it to `api_v1_router` below
|
|
3. Mount the route prefix in the domain's __init__.py
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter
|
|
|
|
# Aggregator list - populated as domains migrate.
|
|
# Each entry is an APIRouter from app/api/v1/<group>/<domain>.py.
|
|
api_v1_router: list[APIRouter] = []
|
|
|
|
# Aggregator router - single mount point for v1.
|
|
# When domains migrate, replace this with a real aggregator:
|
|
# from app.api.v1.public import router as public_router
|
|
# api_v1_router.append(public_router)
|
|
router = APIRouter(prefix="/api/v1", tags=["v1"])
|
|
|
|
|
|
# ── Migrated domains ───────────────────────────────────────────────────
|
|
# Each migrated domain is imported here. The router exposes endpoints
|
|
# at /api/v1/<domain>/* (path defined per-router).
|
|
#
|
|
# During strangelfig, the LEGACY /api/v1/<domain>/* endpoints remain
|
|
# mounted in main.py. The new v1 router is mounted at the same path
|
|
# (FastAPI handles prefix-based routing) - first match wins, so the
|
|
# legacy stays until we explicitly remove it.
|
|
|
|
from app.api.v1.auth.alerts import router as alerts_router # noqa: E402
|
|
|
|
api_v1_router.append(alerts_router)
|
|
|
|
from app.api.v1.public.wallet import router as wallet_router # noqa: E402
|
|
|
|
api_v1_router.append(wallet_router)
|
|
|
|
from app.api.v1.public.token import router as token_router # noqa: E402
|
|
|
|
api_v1_router.append(token_router)
|
|
|
|
from app.api.v1.public.scanner import router as scanner_router # noqa: E402
|
|
|
|
api_v1_router.append(scanner_router)
|
|
|
|
# x402 moved to app.domains.x402 (T34 v2)
|
|
# Old app/api/v1/x402/payments.py removed to avoid model conflicts
|
|
|
|
from app.api.v1.rag.search import router as rag_v2_router # noqa: E402
|
|
|
|
api_v1_router.append(rag_v2_router)
|
|
|
|
from app.api.v1.admin.alerts_webhook import router as admin_alerts_webhook_router # noqa: E402
|
|
|
|
api_v1_router.append(admin_alerts_webhook_router)
|
|
|
|
from app.api.v1.catalog import router as catalog_router # noqa: E402
|
|
|
|
api_v1_router.append(catalog_router)
|
|
|
|
|
|
def build_v1_router() -> APIRouter:
|
|
"""Construct the v1 aggregator with all migrated routes mounted."""
|
|
aggregated = APIRouter(prefix="/api/v1")
|
|
for r in api_v1_router:
|
|
aggregated.include_router(r)
|
|
return aggregated
|