File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed
Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 1313from app .routes .tasks import router as tasks_router
1414from app .telemetry import setup_telemetry , shutdown_telemetry
1515
16+ API_V1_PREFIX = "/api/v1"
17+
1618
1719@asynccontextmanager
1820async def lifespan (app : FastAPI ):
@@ -42,7 +44,7 @@ async def lifespan(app: FastAPI):
4244app .add_middleware (RequestIDMiddleware )
4345
4446app .include_router (metrics_router )
45- app .include_router (auth_router , prefix = "/api/v1" )
46- app .include_router (health_router , prefix = "/api/v1" )
47- app .include_router (tasks_router , prefix = "/api/v1" )
48- app .include_router (tags_router , prefix = "/api/v1" )
47+ app .include_router (auth_router , prefix = API_V1_PREFIX )
48+ app .include_router (health_router , prefix = API_V1_PREFIX )
49+ app .include_router (tasks_router , prefix = API_V1_PREFIX )
50+ app .include_router (tags_router , prefix = API_V1_PREFIX )
Original file line number Diff line number Diff line change 99)
1010
1111
12- async def get_redis () -> Redis :
12+ def get_redis () -> Redis :
1313 return redis_client
Original file line number Diff line number Diff line change 1- from typing import Awaitable , cast
1+ from typing import Annotated , Awaitable , cast
22
33from fastapi import APIRouter , Depends
44from redis .asyncio import Redis
99from app .redis import get_redis
1010
1111router = APIRouter (prefix = "/health" , tags = ["health" ])
12+ RedisClient = Annotated [Redis , Depends (get_redis )]
13+ DbSession = Annotated [AsyncSession , Depends (get_db )]
1214
1315
1416@router .get ("/redis" )
15- async def redis_health (redis : Redis = Depends ( get_redis ) ) -> dict [str , str ]:
17+ async def redis_health (redis : RedisClient ) -> dict [str , str ]:
1618 ok = await cast (Awaitable [bool ], redis .ping ())
1719 return {"redis" : "ok" if ok else "down" }
1820
1921
2022@router .get ("/db" )
21- async def db_health (session : AsyncSession = Depends ( get_db ) ) -> dict [str , str ]:
23+ async def db_health (session : DbSession ) -> dict [str , str ]:
2224 await session .execute (text ("SELECT 1" ))
2325 return {"db" : "ok" }
You can’t perform that action at this time.
0 commit comments