package super

import (
	"os"
	"path/filepath"

	"github.com/gofiber/fiber/v3"
)

// @provider
type staticController struct{}

// Static
//
//	@Tags		Super
//	@Router		/super/*
func (ctl *staticController) static(ctx fiber.Ctx) error {
	root := "/home/rogee/Projects/quyun_v2/frontend/superadmin/dist/"
	param := ctx.Params("*")
	file := filepath.Join(root, param)

	// if file not exits use index.html
	if _, err := os.Stat(file); os.IsNotExist(err) {
		file = filepath.Join(root, "index.html")
	}

	return ctx.SendFile(file)
}
