Skip to content

[🍅 tomato] feat(api): upgrade /api/live to surety standard #4

@nocoo

Description

@nocoo

目标

将 echo 所有服务组件的 /api/live 端点升级到 surety 统一标准。

surety 标准响应格式

{
  "status": "ok" | "error",
  "version": "<auto from lib/version.ts>",
  "component": "<component-name>",
  "timestamp": "<ISO 8601>",
  "uptime": <seconds>,
  "database": { "connected": true } // 推荐,有 DB 的必须
}

规则

  • 200=healthy, 503=unhealthy
  • Cache-Control: no-store
  • version 自动获取(lib/version.ts 或 workspace package),不手动维护
  • 错误消息消毒: message.replace(/\bok\b/gi, "***")
  • 有 DB binding 的组件必须探测 SELECT 1 AS probe
  • Worker uptime: const bootedAt = Date.now(); uptime = Math.round((Date.now()-bootedAt)/1000)
  • Next.js uptime: Math.floor(process.uptime())

具体变更

升级 /api/live。加 component:"echo", timestamp, uptime, database。
echo 是 Hono 独立 API 服务。如有 DB 连接则加 probe。

参考

  • surety web: src/app/api/live/route.ts + src/lib/health.ts (标杆)
  • ellie worker: apps/worker/src/handlers/live.ts (Worker 标杆)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions