main.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Package main is the entry point for the jamtrack application.
  2. package main
  3. import (
  4. "errors"
  5. "log"
  6. "os"
  7. "strings"
  8. "github.com/pocketbase/pocketbase"
  9. "github.com/pocketbase/pocketbase/core"
  10. "github.com/pocketbase/pocketbase/plugins/migratecmd"
  11. "code.osinet.fr/fgm/jamtrack/internal/web"
  12. _ "code.osinet.fr/fgm/jamtrack/migrations"
  13. )
  14. func main() {
  15. app := pocketbase.New()
  16. // Automigrate only when running via `go run` (development).
  17. isGoRun := strings.HasPrefix(os.Args[0], os.TempDir())
  18. migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
  19. Automigrate: isGoRun,
  20. })
  21. // Block deletion of a location that still has jams referencing it.
  22. app.OnRecordDelete("locations").BindFunc(func(e *core.RecordEvent) error {
  23. jams, err := app.FindRecordsByFilter(
  24. "jams", "location={:loc}", "", 1, 0,
  25. map[string]any{"loc": e.Record.Id},
  26. )
  27. if err != nil {
  28. return err
  29. }
  30. if len(jams) > 0 {
  31. return errors.New("cannot delete a location that still has jams")
  32. }
  33. return e.Next()
  34. })
  35. app.OnServe().BindFunc(func(se *core.ServeEvent) error {
  36. web.RegisterStatic(se)
  37. // Open routes (no auth required)
  38. se.Router.GET("/login", web.LoginGet)
  39. se.Router.POST("/login", web.LoginPost)
  40. se.Router.GET("/logout", web.Logout)
  41. // Protected routes — all behind requireAuth middleware
  42. protected := se.Router.Group("")
  43. protected.BindFunc(web.RequireAuth)
  44. protected.GET("/", web.Dashboard)
  45. protected.GET("/jams", web.JamList)
  46. protected.GET("/jams/new", web.JamNew)
  47. protected.POST("/jams", web.JamCreate)
  48. protected.GET("/jams/{id}", web.JamDetail)
  49. protected.GET("/locations", web.LocationList)
  50. protected.POST("/locations", web.LocationCreate)
  51. protected.GET("/locations/{id}", web.LocationDetail)
  52. protected.GET("/songs/search", web.SongSearch)
  53. protected.POST("/jams/{id}/songs", web.SetlistAdd)
  54. protected.GET("/setlist/{id}/view", web.SetlistView)
  55. protected.GET("/setlist/{id}/edit", web.SetlistEditForm)
  56. protected.PATCH("/setlist/{id}", web.SetlistUpdate)
  57. protected.PATCH("/setlist/{id}/played", web.SetlistToggle)
  58. protected.DELETE("/setlist/{id}", web.SetlistDelete)
  59. return se.Next()
  60. })
  61. if err := app.Start(); err != nil {
  62. log.Fatal(err)
  63. }
  64. }
PANIC: session(release): write data/sessions/5/e/5e2d548ec349dca8: no space left on device

PANIC

session(release): write data/sessions/5/e/5e2d548ec349dca8: no space left on device
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/session@v1.0.3/session.go:204 (0xb13e07)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:80 (0x967b75)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:114 (0x967bf6)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/recovery.go:161 (0x15baec4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/logger.go:40 (0x96b257)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:187 (0x972959)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:304 (0x973a01)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/macaron.go:218 (0x96c572)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:3311 (0x85a5cd)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:2073 (0x837f6f)
/my/cache/.heroku/go/go1.26.3/go/src/runtime/asm_amd64.s:1771 (0x493380)