You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.4 KiB
Go
73 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"log"
|
|
"os/exec"
|
|
|
|
"git.phc.dm.unipi.it/phc/website/libs/db"
|
|
"git.phc.dm.unipi.it/phc/website/libs/sl"
|
|
|
|
"git.phc.dm.unipi.it/phc/website/server"
|
|
|
|
"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/model"
|
|
)
|
|
|
|
func init() {
|
|
log.SetFlags(0)
|
|
}
|
|
|
|
func main() {
|
|
l := sl.New()
|
|
|
|
cfg := sl.InjectValue(l, config.Slot, config.Config{
|
|
Mode: "development",
|
|
Host: ":4000",
|
|
})
|
|
|
|
sl.InjectValue[database.Database](l, database.Slot, &database.Memory{
|
|
Users: []model.User{
|
|
{
|
|
Id: "e39ad8d5-a087-4cb2-8fd7-5a6ca3f6a534",
|
|
Username: "claire-doe",
|
|
FullName: db.NewOption("Claire Doe"),
|
|
Email: db.NewOption("claire.doe@example.org"),
|
|
},
|
|
{
|
|
Id: "9b7109cd-95a1-41e9-a9f6-001a32c20ca1",
|
|
Username: "john-smith",
|
|
FullName: db.NewOption("John Smith"),
|
|
Email: db.NewOption("john.smith@example.org"),
|
|
},
|
|
},
|
|
})
|
|
|
|
srv, err := server.Configure(l)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
go func() {
|
|
log.Fatal(srv.Router.Listen(cfg.Host))
|
|
}()
|
|
|
|
r, w := io.Pipe()
|
|
|
|
cmd := exec.Command("npm", "run", "dev")
|
|
cmd.Stdout = w
|
|
|
|
go func() {
|
|
scanner := bufio.NewScanner(r)
|
|
for scanner.Scan() {
|
|
log.Printf(`[cmd/devserver] [vitejs] %s`, scanner.Text())
|
|
}
|
|
}()
|
|
|
|
if err := cmd.Run(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|