chore: more scaffolding

This commit is contained in:
2023-05-04 13:03:57 +02:00
parent 965467d129
commit 2c5d9cf543
10 changed files with 336 additions and 19 deletions
+4
View File
@@ -42,3 +42,7 @@ func init() {
nodes := loadEnv("NODES", "") // for example "node1,node2,node3"
Nodes = strings.Split(nodes, ",")
}
func IsModeDevelopment() bool {
return strings.HasPrefix(strings.ToLower(Mode), "dev")
}
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"github.com/gofiber/fiber/v2"
)
func (r *Router) Api(api fiber.Router) {
func (r *Service) Api(api fiber.Router) {
api.Get("/status", func(c *fiber.Ctx) error {
return c.JSON("ok")
})
+26
View File
@@ -0,0 +1,26 @@
package routes
import (
"path"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/recover"
)
const FrontendOutDir = "./out/frontend"
func (s *Service) Root(r fiber.Router) {
r.Use(logger.New())
r.Use(recover.New())
r.Static("/", FrontendOutDir)
for _, entrypoint := range HtmlEntrypoints {
r.Get(entrypoint.Route, func(c *fiber.Ctx) error {
return c.SendFile(path.Join(FrontendOutDir, entrypoint.Filename))
})
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ package routes
import "git.phc.dm.unipi.it/phc/cluster-dashboard/backend/database"
// Router is the main service that defines all routes, this only depends on the Database service
type Router struct {
type Service struct {
Database database.Database
}