versione prima dle menu della clincia
This commit is contained in:
29
backend/app/api/health.py
Normal file
29
backend/app/api/health.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.config import settings
|
||||
from app.db.session import get_db
|
||||
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["health"])
|
||||
|
||||
|
||||
@router.get("/health")
|
||||
def healthcheck() -> dict[str, str]:
|
||||
return {
|
||||
"status": "ok",
|
||||
"environment": settings.app_env,
|
||||
"app_name": settings.app_name,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/db-health")
|
||||
def database_healthcheck(db: Session = Depends(get_db)) -> dict[str, str | int]:
|
||||
result = db.execute(text("SELECT 1")).scalar_one()
|
||||
return {
|
||||
"status": "ok",
|
||||
"database": "connected",
|
||||
"result": result,
|
||||
"sqlite_file": settings.sqlite_file_path or "not-applicable",
|
||||
}
|
||||
Reference in New Issue
Block a user