From 71089aee0e4f5a16e339ff63b617e4210eebd253 Mon Sep 17 00:00:00 2001 From: Mondo Diaz Date: Wed, 4 Feb 2026 09:49:04 -0600 Subject: [PATCH] refactor: add infrastructure dependency injection to pypi_proxy Add dependency injection helper functions for HttpClientManager and CacheService, along with imports for the new infrastructure modules (http_client, cache_service, db_utils). --- backend/app/pypi_proxy.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/app/pypi_proxy.py b/backend/app/pypi_proxy.py index 1de988b..1e783c5 100644 --- a/backend/app/pypi_proxy.py +++ b/backend/app/pypi_proxy.py @@ -26,12 +26,25 @@ from .database import get_db from .models import UpstreamSource, CachedUrl, Artifact, Project, Package, PackageVersion, ArtifactDependency from .storage import S3Storage, get_storage from .config import get_env_upstream_sources, get_settings +from .http_client import HttpClientManager +from .cache_service import CacheService, CacheCategory +from .db_utils import ArtifactRepository logger = logging.getLogger(__name__) router = APIRouter(prefix="/pypi", tags=["pypi-proxy"]) +def get_http_client(request: Request) -> HttpClientManager: + """Get HttpClientManager from app state.""" + return request.app.state.http_client + + +def get_cache(request: Request) -> CacheService: + """Get CacheService from app state.""" + return request.app.state.cache + + # Timeout configuration for proxy requests PROXY_CONNECT_TIMEOUT = 30.0 PROXY_READ_TIMEOUT = 60.0