forked from Kispi/Core
Simon Giesel
019d0ae566
All checks were successful
continuous-integration/drone/push Build is passing
40 lines
874 B
Go
40 lines
874 B
Go
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)
|
|
}
|
|
|
|
}
|