mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 19:59:40 +02:00
Add lightweight Hono + Bun servers for server-only compute endpoints. CRUD is handled by mana-sync, these handle AI + file upload only. Traces: AI guide generation, location sync (Port 3026) Planta: Photo upload (S3), AI plant analysis (Port 3022) NutriPhi: AI meal analysis (photo+text), recommendations (Port 3023) Each uses @manacore/shared-hono for auth/health/errors. ~100-200 LOC. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
827 B
Go
40 lines
827 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/manacore/shared-go/httputil"
|
|
"time"
|
|
|
|
"github.com/manacore/mana-notify/internal/db"
|
|
)
|
|
|
|
type HealthHandler struct {
|
|
db *db.DB
|
|
startTime time.Time
|
|
}
|
|
|
|
func NewHealthHandler(database *db.DB) *HealthHandler {
|
|
return &HealthHandler{db: database, startTime: time.Now()}
|
|
}
|
|
|
|
func (h *HealthHandler) Health(w http.ResponseWriter, r *http.Request) {
|
|
dbOK := h.db.HealthCheck(r.Context()) == nil
|
|
|
|
status := "healthy"
|
|
if !dbOK {
|
|
status = "unhealthy"
|
|
}
|
|
|
|
httputil.WriteJSON(w, http.StatusOK, map[string]any{
|
|
"status": status,
|
|
"version": "1.0.0",
|
|
"service": "mana-notify",
|
|
"uptime": time.Since(h.startTime).Seconds(),
|
|
"timestamp": time.Now().UTC().Format(time.RFC3339),
|
|
"services": map[string]any{
|
|
"database": dbOK,
|
|
"redis": true,
|
|
},
|
|
})
|
|
}
|