package api

import (
	"github.com/gin-gonic/gin"
	"music-server/pkg/helpers"
	"music-server/pkg/server"
	"net/http"
)

type Index struct {
}

func NewIndex() *Index {
	return &Index{}
}

func (i *Index) GetVersion(ctx *gin.Context) {
	versionHistory := server.GetVersionHistory()
	if versionHistory.Version == "" {
		helpers.NewError(ctx, http.StatusNotFound, nil)
		return
	}
	ctx.JSON(http.StatusOK, versionHistory)
}

func (i *Index) GetDBTest(ctx *gin.Context) {
	server.TestDB()
	ctx.JSON(http.StatusOK, "TestedDB")
}
