feat: implement dynamic API connection status

- Move health endpoint from /health to /api/v1/health
- Update frontend Dashboard to show real connection status
- Add health check query that refreshes every 30 seconds
- Display connected/disconnected status with appropriate icons
- Show loading state while checking connection
This commit is contained in:
Elisiário Couto
2025-09-08 23:58:38 +01:00
committed by Elisiário Couto
parent 417b77539f
commit cb2e70e42d
2 changed files with 54 additions and 5 deletions

View File

@@ -77,9 +77,32 @@ def create_app() -> FastAPI:
version = "unknown"
return {"message": "Leggend API is running", "version": version}
@app.get("/health")
@app.get("/api/v1/health")
async def health():
return {"status": "healthy", "config_loaded": config._config is not None}
"""Health check endpoint for API connectivity"""
try:
from leggend.api.models.common import APIResponse
config_loaded = config._config is not None
return APIResponse(
success=True,
data={
"status": "healthy",
"config_loaded": config_loaded,
"message": "API is running and responsive",
},
message="Health check successful",
)
except Exception as e:
logger.error(f"Health check failed: {e}")
from leggend.api.models.common import APIResponse
return APIResponse(
success=False,
data={"status": "unhealthy", "error": str(e)},
message="Health check failed",
)
return app