package bootstrap

import (
	"net/http"
	"time"

	"github.com/labstack/echo/v4"
)

// @Summary Health check endpoint
// @Description Get comprehensive server health status including system information, dependencies status, and performance metrics. This endpoint is used for monitoring and load balancer health checks.
// @Tags Admin-Health
// @Accept json
// @Produce json
// @Success 200 {object} HealthResponse "System is healthy and operational"
// @Failure 503 {object} HealthResponse "System is unhealthy or experiencing issues"
// @Router /admin/v1/health [get]
func healthHandler(c echo.Context) error {
	return c.JSON(http.StatusOK, HealthResponse{
		Status:  "healthy",
		Time:    time.Now().Unix(),
		Version: "2.0.0",
		Service: "tender-management-api",
		Uptime:  time.Since(time.Now()).String(),
	})
}

// HealthResponse represents the comprehensive health check response
type HealthResponse struct {
	Status  string `json:"status" example:"healthy"`                // Current health status
	Time    int64  `json:"time" example:"1699123456"`               // Current Unix timestamp
	Version string `json:"version" example:"2.0.0"`                 // API version
	Service string `json:"service" example:"tender-management-api"` // Service name
	Uptime  string `json:"uptime,omitempty" example:"24h30m15s"`    // Service uptime duration
}
