Serve pb_public as a static asset

This commit is contained in:
Niko Reunanen 2025-08-03 12:26:36 +03:00
parent d43103570e
commit df6369b9ad
Signed by: nreunane
GPG key ID: D192625387DB0F16

View file

@ -4,6 +4,7 @@ import (
"fmt"
"log"
"net/http"
"os"
"time"
"github.com/pocketbase/dbx"
@ -29,10 +30,17 @@ type Project struct {
func main() {
app := pocketbase.New()
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
Automigrate: false,
})
app.OnServe().BindFunc(func(se *core.ServeEvent) error {
se.Router.GET("/{path...}", apis.Static(os.DirFS("pb_public"), false))
return se.Next()
})
app.OnServe().BindFunc(func(e *core.ServeEvent) error {
e.Router.GET("/api/hours/{organisation}/{year}/{month}", func(c *core.RequestEvent) error {
year := c.Request.PathValue("year")