package version

import (
	"net/http"

	"github.com/pocketbase/pocketbase"
	"github.com/pocketbase/pocketbase/core"
	"github.com/pocketbase/pocketbase/tools/router"
)

var Version string
var BuildDate string
var Company string
var CompanyUrl string

func ServeVersionInfo(app *pocketbase.PocketBase, se *core.ServeEvent) *router.Route[*core.RequestEvent] {
	return se.Router.GET("/api/version/send", func(e *core.RequestEvent) error {

		return e.JSON(http.StatusOK, map[string]string{
			"version":     Version,
			"build_date":  BuildDate,
			"company":     Company,
			"company_url": CompanyUrl,
		})
	})
}
