generated from coulomb/repo-seed
Start Core Hub FastAPI replacement foundation
This commit is contained in:
35
src/core_hub/app.py
Normal file
35
src/core_hub/app.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
from core_hub import __version__
|
||||
from core_hub.api.v2 import router as api_v2_router
|
||||
from core_hub.config import get_settings
|
||||
from core_hub.schemas import HealthResponse, ReadinessResponse
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
settings = get_settings()
|
||||
app = FastAPI(
|
||||
title="Core Hub API",
|
||||
version=__version__,
|
||||
description="Third-generation production interaction framework API.",
|
||||
)
|
||||
|
||||
@app.get("/healthz", response_model=HealthResponse, tags=["system"])
|
||||
def healthz() -> HealthResponse:
|
||||
return HealthResponse(service="core-hub", status="ok", version=__version__)
|
||||
|
||||
@app.get("/readyz", response_model=ReadinessResponse, tags=["system"])
|
||||
def readyz() -> ReadinessResponse:
|
||||
checks = {
|
||||
"configuration": "ok",
|
||||
"database_url": "configured" if settings.database_url else "missing",
|
||||
"api_auth": "configured" if settings.auth_configured else "not_configured",
|
||||
}
|
||||
status = "ok" if checks["database_url"] == "configured" else "degraded"
|
||||
return ReadinessResponse(service="core-hub", status=status, checks=checks)
|
||||
|
||||
app.include_router(api_v2_router)
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
Reference in New Issue
Block a user