35 lines
769 B
Python
35 lines
769 B
Python
"""Health and readiness endpoints."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone, timedelta
|
|
|
|
from fastapi import APIRouter
|
|
from pydantic import BaseModel
|
|
|
|
from app.core.config import get_settings
|
|
|
|
router = APIRouter(tags=["health"])
|
|
|
|
_KST = timezone(timedelta(hours=9))
|
|
|
|
|
|
class HealthResponse(BaseModel):
|
|
status: str
|
|
service: str
|
|
version: str
|
|
checked_at: str
|
|
db_enabled: bool
|
|
|
|
|
|
@router.get("/health", response_model=HealthResponse)
|
|
def healthcheck() -> HealthResponse:
|
|
settings = get_settings()
|
|
return HealthResponse(
|
|
status="ok",
|
|
service="portfolio-hub",
|
|
version=settings.app_version,
|
|
checked_at=datetime.now(_KST).isoformat(),
|
|
db_enabled=settings.db_enabled,
|
|
)
|