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.
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"git.phc.dm.unipi.it/phc/website/appunti"
|
|
"git.phc.dm.unipi.it/phc/website/articles"
|
|
"git.phc.dm.unipi.it/phc/website/auth"
|
|
"git.phc.dm.unipi.it/phc/website/config"
|
|
"git.phc.dm.unipi.it/phc/website/database"
|
|
"git.phc.dm.unipi.it/phc/website/handler"
|
|
"git.phc.dm.unipi.it/phc/website/lista_utenti"
|
|
"git.phc.dm.unipi.it/phc/website/server"
|
|
"git.phc.dm.unipi.it/phc/website/storia"
|
|
"git.phc.dm.unipi.it/phc/website/templates"
|
|
"git.phc.dm.unipi.it/phc/website/util"
|
|
)
|
|
|
|
func main() {
|
|
config.Load()
|
|
|
|
auth := auth.NewDefaultService(config.AuthServiceHost)
|
|
|
|
// Create database connection and apply pending migrations
|
|
db := util.Must(database.NewSqlite3Database("phc-server.local.db"))
|
|
if err := db.Migrate("./database/migrations"); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
app := server.NewFiberServer(&handler.DefaultHandler{
|
|
AuthService: auth,
|
|
Renderer: templates.NewRenderer(
|
|
"./_views/",
|
|
"./_views/base.html",
|
|
"./_views/partials/*.html",
|
|
),
|
|
NewsArticlesRegistry: articles.NewRegistry("./_content/news"),
|
|
GuideArticlesRegistry: articles.NewRegistry("./_content/guide"),
|
|
Storia: &storia.JsonFileStoria{
|
|
Path: "./_content/storia.yaml",
|
|
},
|
|
ListaUtenti: util.Must(lista_utenti.New(auth, config.ListaUtenti)),
|
|
AppuntiService: &appunti.DefaultService{
|
|
DB: db,
|
|
},
|
|
})
|
|
|
|
log.Printf("Starting server on host %q", config.Host)
|
|
if err := app.Listen(config.Host); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|