forked from phc/cluster-dashboard
chore: more scaffolding
This commit is contained in:
+2
-16
@@ -6,14 +6,11 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/logger"
|
||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||
|
||||
"git.phc.dm.unipi.it/phc/cluster-dashboard/backend/config"
|
||||
"git.phc.dm.unipi.it/phc/cluster-dashboard/backend/database"
|
||||
@@ -21,28 +18,17 @@ import (
|
||||
"git.phc.dm.unipi.it/phc/cluster-dashboard/backend/routes"
|
||||
)
|
||||
|
||||
const FrontendOutDir = "./out/frontend"
|
||||
|
||||
func main() {
|
||||
ex := &executor.Mock{} // to try out locally this project in a reasonable way
|
||||
db := database.NewSimpleDatabase(ex)
|
||||
|
||||
router := &routes.Router{
|
||||
router := &routes.Service{
|
||||
Database: db,
|
||||
}
|
||||
|
||||
app := fiber.New()
|
||||
|
||||
app.Use(logger.New())
|
||||
app.Use(recover.New())
|
||||
|
||||
app.Static("/", FrontendOutDir)
|
||||
for _, entrypoint := range routes.HtmlEntrypoints {
|
||||
app.Get(entrypoint.Route, func(c *fiber.Ctx) error {
|
||||
return c.SendFile(path.Join(FrontendOutDir, entrypoint.Filename))
|
||||
})
|
||||
}
|
||||
|
||||
app.Route("/", router.Root)
|
||||
app.Route("/api", router.Api)
|
||||
|
||||
if strings.HasPrefix(config.Mode, "dev") {
|
||||
|
||||
Reference in New Issue
Block a user