package main import ( "net/http" "time" "cliffbreak.de/hgoe-sas-server/pkg/middlewares" "cliffbreak.de/hgoe-sas-server/pkg/utils" "github.com/labstack/echo/v5" "github.com/pocketbase/pocketbase" "github.com/pocketbase/pocketbase/core" "github.com/pterm/pterm" ) func main() { pterm.Info.Println("Loading environment variables...") utils.LoadEnv() pterm.Info.Println("Starting PocketBase server...") app := pocketbase.New() app.OnBeforeServe().Add(middlewares.ServeSPA(utils.GetEnv("WEBAPP", "./webapp"))) app.OnBeforeServe().Add(func(e *core.ServeEvent) error { e.Router.AddRoute(echo.Route{ Method: http.MethodGet, Path: "/api/time", Handler: func(c echo.Context) error { return c.String(http.StatusOK, time.Now().Format(time.RFC3339)) }, }) return nil }) if err := app.Start(); err != nil { pterm.Fatal.Println(err) } }