package api

import (
	"net/http"
	"time"
)

// handleHealth is the liveness probe. It reports only on this process — it does
// not touch PocketBase, so it stays fast and stays "ok" even while a dependency
// is down. Use /api/status for dependency health.
func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) {
	writeJSON(w, http.StatusOK, map[string]any{
		"status":  "ok",
		"service": "drivervault-api",
		// The operator-chosen display name, so a client adding this server by URL
		// can label it without a second (authenticated) call.
		"name": s.serverName(),
		"time": time.Now().UTC().Format(time.RFC3339),
	})
}
