first commit
Some checks failed
CI / backend (push) Has been cancelled
CI / frontend (push) Has been cancelled

This commit is contained in:
2026-07-23 02:38:05 +03:00
commit 8757bec8ac
335 changed files with 61527 additions and 0 deletions

40
backend/api/health.py Normal file
View File

@@ -0,0 +1,40 @@
"""Endpoint для проверки здоровья."""
from fastapi import APIRouter, Depends
from sqlalchemy import text
from sqlalchemy.ext.asyncio import AsyncSession
from core.config import get_settings
from core.db import get_session
from core.redis import redis_client
router = APIRouter()
@router.get("/api/health")
async def health(session: AsyncSession = Depends(get_session)) -> dict[str, bool | str]:
"""Отчет о статусе приложения и связи с БД/Redis.
Поле `version` — версия инстанса (`VIDCONF_VERSION` из `.env`,
пишет `install.sh` из корневого файла `VERSION`); футер админки
берёт его отсюда, а не из версии сборки фронтенда.
"""
db_ok = False
try:
await session.execute(text("SELECT 1"))
db_ok = True
except Exception: # noqa: BLE001
db_ok = False
redis_ok = False
try:
redis_ok = bool(await redis_client.ping())
except Exception: # noqa: BLE001
redis_ok = False
return {
"status": "ok",
"db": db_ok,
"redis": redis_ok,
"version": get_settings().vidconf_version,
}