69a232d08a
- FastAPI: POST /api/v1/events, GET /health, JSON Schema validation - PostgreSQL models, Alembic migration, bootstrap API key - deploy/docker-compose.yml, .env.example - docs/install-ubuntu-24.04.md, updated work-plan (agents first)
22 lines
520 B
Python
22 lines
520 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy import text
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.database import get_db
|
|
|
|
router = APIRouter(tags=["health"])
|
|
|
|
|
|
@router.get("/health")
|
|
def health(db: Session = Depends(get_db)) -> dict:
|
|
db_status = "ok"
|
|
try:
|
|
db.execute(text("SELECT 1"))
|
|
except Exception:
|
|
db_status = "error"
|
|
return {
|
|
"status": "ok" if db_status == "ok" else "degraded",
|
|
"database": db_status,
|
|
"service": "security-alert-center",
|
|
}
|