Initial commit
Made-with: Cursor
This commit is contained in:
19
backend/app/deps.py
Normal file
19
backend/app/deps.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""Sdílené FastAPI závislosti (DB pool)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncpg
|
||||
from fastapi import HTTPException
|
||||
|
||||
_pg_pool: asyncpg.Pool | None = None
|
||||
|
||||
|
||||
def set_pg_pool(pool: asyncpg.Pool | None) -> None:
|
||||
global _pg_pool
|
||||
_pg_pool = pool
|
||||
|
||||
|
||||
async def get_pg_pool() -> asyncpg.Pool:
|
||||
if _pg_pool is None:
|
||||
raise HTTPException(status_code=503, detail="Database pool not ready")
|
||||
return _pg_pool
|
||||
Reference in New Issue
Block a user