@@ -3,15 +3,10 @@ package main
3
3
import (
4
4
"log"
5
5
"os"
6
- "path/filepath"
7
- "strings"
8
6
"time"
9
7
10
8
"github.com/pocketbase/pocketbase"
11
- "github.com/pocketbase/pocketbase/apis"
12
9
"github.com/pocketbase/pocketbase/core"
13
- "github.com/pocketbase/pocketbase/plugins/ghupdate"
14
- "github.com/pocketbase/pocketbase/plugins/jsvm"
15
10
"github.com/pocketbase/pocketbase/plugins/migratecmd"
16
11
)
17
12
@@ -21,39 +16,6 @@ func main() {
21
16
// ---------------------------------------------------------------
22
17
// Optional plugin flags:
23
18
// ---------------------------------------------------------------
24
-
25
- var hooksDir string
26
- app .RootCmd .PersistentFlags ().StringVar (
27
- & hooksDir ,
28
- "hooksDir" ,
29
- "" ,
30
- "the directory with the JS app hooks" ,
31
- )
32
-
33
- var hooksWatch bool
34
- app .RootCmd .PersistentFlags ().BoolVar (
35
- & hooksWatch ,
36
- "hooksWatch" ,
37
- true ,
38
- "auto restart the app on pb_hooks file change" ,
39
- )
40
-
41
- var hooksPool int
42
- app .RootCmd .PersistentFlags ().IntVar (
43
- & hooksPool ,
44
- "hooksPool" ,
45
- 25 ,
46
- "the total prewarm goja.Runtime instances for the JS app hooks execution" ,
47
- )
48
-
49
- var migrationsDir string
50
- app .RootCmd .PersistentFlags ().StringVar (
51
- & migrationsDir ,
52
- "migrationsDir" ,
53
- "" ,
54
- "the directory with the user defined migrations" ,
55
- )
56
-
57
19
var automigrate bool
58
20
app .RootCmd .PersistentFlags ().BoolVar (
59
21
& automigrate ,
@@ -62,22 +24,6 @@ func main() {
62
24
"enable/disable auto migrations" ,
63
25
)
64
26
65
- var publicDir string
66
- app .RootCmd .PersistentFlags ().StringVar (
67
- & publicDir ,
68
- "publicDir" ,
69
- defaultPublicDir (),
70
- "the directory to serve static files" ,
71
- )
72
-
73
- var indexFallback bool
74
- app .RootCmd .PersistentFlags ().BoolVar (
75
- & indexFallback ,
76
- "indexFallback" ,
77
- true ,
78
- "fallback the request to index.html on missing static path (eg. when pretty urls are used with SPA)" ,
79
- )
80
-
81
27
var queryTimeout int
82
28
app .RootCmd .PersistentFlags ().IntVar (
83
29
& queryTimeout ,
@@ -92,46 +38,28 @@ func main() {
92
38
// Plugins and hooks:
93
39
// ---------------------------------------------------------------
94
40
95
- // load jsvm (hooks and migrations)
96
- jsvm .MustRegister (app , jsvm.Config {
97
- MigrationsDir : migrationsDir ,
98
- HooksDir : hooksDir ,
99
- HooksWatch : hooksWatch ,
100
- HooksPoolSize : hooksPool ,
101
- })
102
-
103
41
// migrate command (with js templates)
104
42
migratecmd .MustRegister (app , app .RootCmd , migratecmd.Config {
105
43
TemplateLang : migratecmd .TemplateLangJS ,
106
44
Automigrate : automigrate ,
107
- Dir : migrationsDir ,
45
+ // Dir: migrationsDir,
108
46
})
109
47
110
- // GitHub selfupdate
111
- ghupdate .MustRegister (app , app .RootCmd , ghupdate.Config {})
48
+ // // GitHub selfupdate
49
+ // ghupdate.MustRegister(app, app.RootCmd, ghupdate.Config{})
112
50
113
51
app .OnAfterBootstrap ().PreAdd (func (e * core.BootstrapEvent ) error {
114
52
app .Dao ().ModelQueryTimeout = time .Duration (queryTimeout ) * time .Second
115
53
return nil
116
54
})
117
55
118
- app .OnBeforeServe ().Add (func (e * core.ServeEvent ) error {
119
- // serves static files from the provided public dir (if exists)
120
- e .Router .GET ("/*" , apis .StaticDirectoryHandler (os .DirFS (publicDir ), indexFallback ))
121
- return nil
122
- })
56
+ // app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
57
+ // // serves static files from the provided public dir (if exists)
58
+ // e.Router.GET("/*", apis.StaticDirectoryHandler(os.DirFS(publicDir), indexFallback))
59
+ // return nil
60
+ // })
123
61
124
62
if err := app .Start (); err != nil {
125
63
log .Fatal (err )
126
64
}
127
65
}
128
-
129
- // the default pb_public dir location is relative to the executable
130
- func defaultPublicDir () string {
131
- if strings .HasPrefix (os .Args [0 ], os .TempDir ()) {
132
- // most likely ran with go run
133
- return "./pb_public"
134
- }
135
-
136
- return filepath .Join (os .Args [0 ], "../pb_public" )
137
- }
0 commit comments