managarten/services/mana-notify/internal/handler/health.go
Till JS d3d11e661d feat(apps): create Hono compute servers for Traces, Planta, NutriPhi
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>
2026-03-28 16:16:57 +01:00

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