routes.py 659 B

1234567891011121314151617181920
  1. from fastapi import APIRouter, Depends
  2. from sqlalchemy import text
  3. from sqlalchemy.orm import Session
  4. from core_domain import ServiceDescriptor, ServiceHealth
  5. from app.db.session import get_db
  6. router = APIRouter()
  7. @router.get("/health", response_model=ServiceDescriptor)
  8. def health_check(db: Session = Depends(get_db)) -> ServiceDescriptor:
  9. db.execute(text("SELECT 1"))
  10. return ServiceDescriptor(name="api-gateway")
  11. @router.get("/ready", response_model=ServiceHealth)
  12. def readiness_check(db: Session = Depends(get_db)) -> ServiceHealth:
  13. db.execute(text("SELECT 1"))
  14. return ServiceHealth(service="api-gateway", status="ok", database="ok")