844d8416bd
- Set up the main application structure with App component and routing. - Implemented global state management for UI theme using Zustand. - Created API utilities for fetching system status. - Developed system status page with responsive design and theme toggle. - Added testing setup with Vitest and initial tests for system status page. - Configured TypeScript with appropriate settings for the application. - Integrated Tailwind CSS for styling and responsive design. - Established Vite configuration for development and testing environments.
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
"""Operational endpoints that do not belong to a business context."""
|
|
|
|
from typing import Annotated, Literal
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from pydantic import BaseModel
|
|
|
|
from zhixing_server.bootstrap.config import Settings, get_settings
|
|
|
|
operational_router = APIRouter()
|
|
system_router = APIRouter()
|
|
|
|
|
|
class HealthResponse(BaseModel):
|
|
"""Minimal response used by container health probes."""
|
|
|
|
status: Literal["ok"]
|
|
|
|
|
|
class SystemStatusResponse(HealthResponse):
|
|
"""Non-domain runtime metadata displayed by the frontend smoke slice."""
|
|
|
|
service: str
|
|
environment: str
|
|
|
|
|
|
@operational_router.get("/healthz", response_model=HealthResponse, include_in_schema=False)
|
|
def health() -> HealthResponse:
|
|
"""Report whether the HTTP process can serve requests.
|
|
|
|
Returns:
|
|
A stable response suitable for container health checks.
|
|
"""
|
|
return HealthResponse(status="ok")
|
|
|
|
|
|
@system_router.get("/status", response_model=SystemStatusResponse)
|
|
def system_status(settings: Annotated[Settings, Depends(get_settings)]) -> SystemStatusResponse:
|
|
"""Expose safe runtime metadata for end-to-end connectivity checks.
|
|
|
|
Args:
|
|
settings: Validated process settings injected by FastAPI.
|
|
|
|
Returns:
|
|
The service name, environment, and current availability state.
|
|
"""
|
|
return SystemStatusResponse(
|
|
status="ok",
|
|
service=settings.app_name,
|
|
environment=settings.app_env,
|
|
)
|