managarten/services/mana-notify-go/internal/handler/health.go
Till JS 585cdc1753 feat(mana-notify): rewrite notification service from NestJS to Go
Replaces the NestJS mana-notify service with a Go implementation.
Features: 4 notification channels (email/SMTP, Expo push, Matrix,
webhook), goroutine worker pool with retry/backoff (replaces BullMQ),
Go template engine (replaces Handlebars), PostgreSQL with auto-migrations
(5 tables), user preferences with quiet hours, idempotency via
externalId, batch sending, scheduled delivery, JWT + service key auth.

22 API endpoints, 1:1 compatible. Binary: 21 MB.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 22:28:19 +01:00

38 lines
775 B
Go

package handler
import (
"net/http"
"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"
}
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,
},
})
}