Files
zhixing-system/zhixing-server/src/zhixing_server/interfaces/http/system.py
T
yuxuanhui 844d8416bd feat: initialize zhixing-web with React, React Router, and Tailwind CSS
- 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.
2026-08-03 13:47:24 +08:00

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,
)