2026-08-31 21:05:24 +08:00

39 lines
1.0 KiB
Python

"""FastAPI application entry point."""
from fastapi import FastAPI
from pydantic import BaseModel
from ekp_core.config import Settings, get_settings
class HealthResponse(BaseModel):
"""Health endpoint response."""
status: str
application: str
environment: str
def create_app(settings: Settings | None = None) -> FastAPI:
"""Create the API application with explicit, testable settings."""
resolved_settings = settings or get_settings()
application = FastAPI(
title=resolved_settings.app_name,
version="0.1.0",
docs_url=f"{resolved_settings.api_prefix}/docs",
openapi_url=f"{resolved_settings.api_prefix}/openapi.json",
)
@application.get("/healthz", response_model=HealthResponse, tags=["system"])
async def health() -> HealthResponse:
return HealthResponse(
status="ok",
application=resolved_settings.app_name,
environment=resolved_settings.app_env,
)
return application
app = create_app()