//
// Copyright (C) 2025 veypi <i@veypi.com>
// 2025-03-04 16:08:06
// Distributed under terms of the MIT license.
//

package vbase

import (
	"embed"

	"github.com/veypi/vbase/api"
	"github.com/veypi/vbase/auth"
	"github.com/veypi/vbase/cfg"
	"github.com/veypi/vbase/models"
	"github.com/veypi/vhtml"
	vhtmlui "github.com/veypi/vhtml-ui"
	"github.com/veypi/vigo"
)

var Router = vigo.NewRouter()
var (
	NewAuth = auth.Factory.New
	Config  = cfg.Global
)

type Options = cfg.Options

func Init() error {
	return models.Migrate()
}

//go:embed ui
var uifs embed.FS

func init() {
	Router.Extend("/api", api.Router)
	Router.Extend("v", vhtmlui.Router)
	Router.Extend("vhtml", vhtml.Router)
	vhtml.WrapUI(Router, uifs)
}
