Aggiunta endpoint healtcheck, modelli user,

logiche sicurezza e file config variabili
This commit is contained in:
2026-05-02 14:05:39 +02:00
parent cccfc51731
commit 6c467b6e77
4 changed files with 169 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import text
import redis.asyncio as aioredis
from app.core.deps import get_db
from app.core.config import settings
router = APIRouter()
@router.get("/health")
async def health_check(db: AsyncSession = Depends(get_db)):
checks = {"status": "ok", "db": "ok", "redis": "ok"}
try:
await db.execute(text("SELECT 1"))
except Exception as e:
checks["db"] = f"error: {str(e)}"
checks["status"] = "degraded"
try:
r = aioredis.from_url(settings.redis_url)
await r.ping()
await r.aclose()
except Exception as e:
checks["redis"] = f"error: {str(e)}"
checks["status"] = "degraded"
return checks