chore: refactor main

This commit is contained in:
2023-06-13 23:35:49 +02:00
parent e34f91fce6
commit e36fddb2b3
5 changed files with 33 additions and 26 deletions
+7 -6
View File
@@ -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() {