2023-10-26 20:34:59 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-03-27 14:36:45 +00:00
|
|
|
"git.stuve.uni-ulm.de/StuVe-IT/stuve-it-backend/ldapLogin"
|
|
|
|
"git.stuve.uni-ulm.de/StuVe-IT/stuve-it-backend/ldapSync"
|
|
|
|
"git.stuve.uni-ulm.de/StuVe-IT/stuve-it-backend/logger"
|
|
|
|
"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
|
2024-03-27 14:36:45 +00:00
|
|
|
err := godotenv.Load(".env.local")
|
|
|
|
if err != nil {
|
|
|
|
logger.LogInfoF("The file '.env.local' could not be loaded.")
|
|
|
|
}
|
|
|
|
err = godotenv.Load(".env")
|
|
|
|
if err != nil {
|
|
|
|
logger.LogInfoF("The file '.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)
|
|
|
|
})
|
|
|
|
|
|
|
|
// setup ldap login
|
|
|
|
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
|
|
|
return ldapLogin.InitLDAPLogin(app, e)
|
|
|
|
})
|
|
|
|
|
2024-03-27 14:36:45 +00:00
|
|
|
// setup qr api
|
|
|
|
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
|
|
|
return qrApi.InitQRApi(app, e)
|
|
|
|
})
|
|
|
|
|
2023-10-26 20:34:59 +00:00
|
|
|
// start app
|
|
|
|
if err := app.Start(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|