package controllers

import (
	"backend/internal/utils"
	u "pkg/utils"
	"time"

	"github.com/labstack/echo/v5"
	"github.com/spf13/cast"
)

func GetConfig(c *echo.Context) error {
	return utils.HTTPSuccessHandler(c, map[string]any{
		"site_title":  u.GetEnvMapString("site.title"),
		"site_desc":   u.GetEnvMapString("site.desc"),
		"site_url":    u.GetEnv("site.url"),
		"site_icon":   u.GetEnvWithDefault("site.icon", "/logo.png"),
		"site_bg_url": u.GetEnvWithDefault("site.bg_url", "https://img.fudaoyuan.icu/api/1/random/?scale_min=1.5&webp=true&md=false&format=302"),
		"version":     u.GetEnvWithDefault("VERSION", "dev"),
		"build_time":  cast.ToInt(u.GetEnvWithDefault("BUILD_TIME", cast.ToString(time.Now().Unix()))),
	})
}
