25 lines
684 B
Python
25 lines
684 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import text
|
|
from ..db import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health")
|
|
def health(db: Session = Depends(get_db)):
|
|
# Verifica connessione DB e schema
|
|
try:
|
|
result = db.execute(text("SELECT current_schema(), current_user, now();")).first()
|
|
return {
|
|
"status": "ok",
|
|
"service": "rendicontazione-api",
|
|
"db": {
|
|
"schema": result[0],
|
|
"user": result[1],
|
|
"now": str(result[2]),
|
|
},
|
|
}
|
|
except Exception as e:
|
|
return {"status": "degraded", "error": str(e)}
|