-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.go
83 lines (66 loc) · 1.89 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"log"
"os"
"github.com/blackfyre/wga/crontab"
"github.com/blackfyre/wga/handlers"
"github.com/blackfyre/wga/hooks"
_ "github.com/blackfyre/wga/migrations"
"github.com/blackfyre/wga/utils"
"github.com/blackfyre/wga/utils/seed"
"github.com/blackfyre/wga/utils/sitemap"
"github.com/joho/godotenv"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/plugins/migratecmd"
"github.com/spf13/cobra"
)
func main() {
_ = godotenv.Load()
app := pocketbase.NewWithConfig(pocketbase.Config{
DefaultDataDir: "./wga_data",
})
// app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
// e.Router.Use(middleware.CSRFWithConfig(middleware.CSRFConfig{
// TokenLookup: "header:X-XSRF-TOKEN",
// }))
// return nil
// })
handlers.RegisterHandlers(app)
hooks.RegisterHooks(app)
crontab.RegisterCronJobs(app)
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
// enable auto creation of migration files when making collection changes in the Admin UI
// (the isGoRun check is to enable it only during development)
Automigrate: false,
})
app.RootCmd.AddCommand(&cobra.Command{
Use: "generate-sitemap",
Short: "Generate sitemap",
Run: func(cmd *cobra.Command, args []string) {
sitemap.GenerateSiteMap(app)
},
})
app.RootCmd.AddCommand(&cobra.Command{
Use: "generate-music-urls",
Short: "Generate music urls",
Run: func(cmd *cobra.Command, args []string) {
utils.ParseMusicListToUrls("./assets/reference/musics.json")
},
})
if os.Getenv("WGA_ENV") == "development" {
app.RootCmd.AddCommand(&cobra.Command{
Use: "seed:images",
Short: "Seed images to the specified S3 bucket",
Run: func(cmd *cobra.Command, args []string) {
err := seed.SeedImages(app)
if err != nil {
log.Fatal(err)
}
log.Println("Done seeding images")
},
})
}
if err := app.Start(); err != nil {
log.Fatal(err)
}
}