MCPcopy
hub / github.com/pocketbase/pocketbase / Register

Function Register

plugins/jsvm/jsvm.go:128–175  ·  view source on GitHub ↗

Register registers the jsvm plugin in the provided app instance.

(app core.App, config Config)

Source from the content-addressed store, hash-verified

126
127// Register registers the jsvm plugin in the provided app instance.
128func Register(app core.App, config Config) error {
129 p := &plugin{app: app, config: config}
130
131 if p.config.HooksDir == "" {
132 p.config.HooksDir = filepath.Join(app.DataDir(), "../pb_hooks")
133 }
134
135 if p.config.MigrationsDir == "" {
136 p.config.MigrationsDir = filepath.Join(app.DataDir(), "../pb_migrations")
137 }
138
139 if p.config.HooksFilesPattern == "" {
140 p.config.HooksFilesPattern = `^.*(\.pb\.js|\.pb\.ts)$`
141 }
142
143 if p.config.MigrationsFilesPattern == "" {
144 p.config.MigrationsFilesPattern = `^.*(\.js|\.ts)$`
145 }
146
147 if p.config.TypesDir == "" {
148 p.config.TypesDir = app.DataDir()
149 }
150
151 p.app.OnBootstrap().BindFunc(func(e *core.BootstrapEvent) error {
152 err := e.Next()
153 if err != nil {
154 return err
155 }
156
157 // ensure that the user has the latest types declaration
158 err = p.refreshTypesFile()
159 if err != nil {
160 color.Yellow("Unable to refresh app types file: %v", err)
161 }
162
163 return nil
164 })
165
166 if err := p.registerMigrations(); err != nil {
167 return fmt.Errorf("registerMigrations: %w", err)
168 }
169
170 if err := p.registerHooks(); err != nil {
171 return fmt.Errorf("registerHooks: %w", err)
172 }
173
174 return nil
175}
176
177type plugin struct {
178 app core.App

Callers 1

MustRegisterFunction · 0.70

Calls 7

refreshTypesFileMethod · 0.95
registerMigrationsMethod · 0.95
registerHooksMethod · 0.95
DataDirMethod · 0.65
OnBootstrapMethod · 0.65
NextMethod · 0.65
BindFuncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…