diff --git a/client/styles/main.scss b/client/styles/main.scss index d9aa9ab..3d42bd5 100644 --- a/client/styles/main.scss +++ b/client/styles/main.scss @@ -382,8 +382,8 @@ footer { .project { // background: #fcddff; - background: #ffa89c; - // background: #a2d4f3; + // background: #ffa89c; + background: #a2d4f3; color: #000e; border: 3px solid #222; diff --git a/cmd/dev-server/main.go b/cmd/dev-server/main.go index 7261445..7b2964b 100644 --- a/cmd/dev-server/main.go +++ b/cmd/dev-server/main.go @@ -13,6 +13,7 @@ import ( "git.phc.dm.unipi.it/phc/website/server/config" "git.phc.dm.unipi.it/phc/website/server/database" + "git.phc.dm.unipi.it/phc/website/server/listautenti" "git.phc.dm.unipi.it/phc/website/server/model" ) @@ -23,10 +24,7 @@ func init() { func main() { l := sl.New() - cfg := sl.InjectValue(l, config.Slot, config.Config{ - Mode: "development", - Host: ":4000", - }) + cfg := sl.InjectValue(l, config.Slot, config.TestingDevelopmentConfig) sl.InjectValue[database.Database](l, database.Slot, &database.Memory{ Users: []model.User{ @@ -45,7 +43,10 @@ func main() { }, }) - srv, err := server.Configure(l) + sl.InjectLazy(l, server.Slot, server.Configure) + sl.InjectLazy(l, listautenti.Slot, listautenti.Configure) + + srv, err := sl.Use(l, server.Slot) if err != nil { log.Fatal(err) } @@ -56,7 +57,7 @@ func main() { r, w := io.Pipe() - cmd := exec.Command("npm", "run", "dev") + cmd := exec.Command("pnpm", "run", "dev") cmd.Stdout = w go func() { diff --git a/server/config/config.go b/server/config/config.go index 4a52955..650a2b6 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -6,24 +6,14 @@ import ( "github.com/joho/godotenv" ) -var Slot = sl.NewSlot[Config]() - -var TestingProductionConfig = Config{ - Mode: "production", - Host: ":4000", -} - -var TestingDevelopmentConfig = Config{ - Mode: "development", - Host: ":4000", -} - type Config struct { Mode string Host string } -func Load(l *sl.ServiceLocator) (Config, error) { +var Slot = sl.NewSlot[Config]() + +func Configure(l *sl.ServiceLocator) (Config, error) { m, err := godotenv.Read(".env") if err != nil { return Config{}, err @@ -43,3 +33,13 @@ func Load(l *sl.ServiceLocator) (Config, error) { return cfg, nil } + +var TestingProductionConfig = Config{ + Mode: "production", + Host: ":4000", +} + +var TestingDevelopmentConfig = Config{ + Mode: "development", + Host: ":4000", +} diff --git a/server/listautenti/listautenti.go b/server/listautenti/listautenti.go index 96fb739..72e33c2 100644 --- a/server/listautenti/listautenti.go +++ b/server/listautenti/listautenti.go @@ -9,15 +9,19 @@ import ( "git.phc.dm.unipi.it/phc/website/server/routes" ) -func Configure(l *sl.ServiceLocator) error { +type ListaUtenti struct{} + +var Slot = sl.NewSlot[*ListaUtenti]() + +func Configure(l *sl.ServiceLocator) (*ListaUtenti, error) { db, err := sl.Use(l, database.Slot) if err != nil { - return err + return nil, err } r, err := sl.Use(l, routes.Root) if err != nil { - return err + return nil, err } r.Get("/api/lista-utenti", func(c *fiber.Ctx) error { @@ -30,5 +34,5 @@ func Configure(l *sl.ServiceLocator) error { return c.JSON(users) }) - return nil + return &ListaUtenti{}, nil } diff --git a/server/server.go b/server/server.go index 63e2d58..0817a9a 100644 --- a/server/server.go +++ b/server/server.go @@ -10,13 +10,15 @@ import ( type Server struct{ Router *fiber.App } +var Slot = sl.NewSlot[*Server]() + func Configure(l *sl.ServiceLocator) (*Server, error) { r := fiber.New(fiber.Config{}) r.Static("/assets", "./out/frontend/assets") sl.InjectValue(l, routes.Root, fiber.Router(r)) - if err := listautenti.Configure(l); err != nil { + if err := sl.Invoke(l, listautenti.Slot); err != nil { return nil, err }