stuve-it-backend/main/main.go

48 lines
1.1 KiB
Go
Raw Normal View History

2023-10-26 20:34:59 +00:00
package main
import (
"git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/ldapApi"
"git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/logger"
"git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/messages"
"git.stuve.uni-ulm.de/stuve-it/stuve-it-backend/qrApi"
2023-10-26 20:34:59 +00:00
"github.com/joho/godotenv"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/core"
"log"
)
func main() {
// load env
err := godotenv.Load(".env.local", ".env")
if err != nil {
logger.LogInfoF("The file '.env.local' / '.env' could not be loaded.")
}
2023-10-26 20:34:59 +00:00
// create app
app := pocketbase.New()
// setup ldap sync
//app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
// return ldapSync.InitLdapSync(app)
//})
2023-10-26 20:34:59 +00:00
// setup ldap login
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
return ldapApi.InitLdapApi(app, e)
2023-10-26 20:34:59 +00:00
})
// setup qr api
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
return qrApi.InitQRApi(app, e)
})
// setup messages email notifications
app.OnBeforeServe().Add(func(e *core.ServeEvent) error { return messages.InitMessages(app, e) })
2023-10-26 20:34:59 +00:00
// start app
if err := app.Start(); err != nil {
log.Fatal(err)
}
}