package module import ( "context" "forge.cadoles.com/arcad/edge/pkg/app" "github.com/dop251/goja" "github.com/pkg/errors" "gitlab.com/wpetit/goweb/logger" ) type LifecycleModule struct { server *app.Server } func (m *LifecycleModule) Name() string { return "lifecycle" } func (m *LifecycleModule) Export(export *goja.Object) { } func (m *LifecycleModule) OnInit() error { if _, err := m.server.ExecFuncByName("onInit"); err != nil { if errors.Is(err, app.ErrFuncDoesNotExist) { logger.Warn(context.Background(), "could not find onInit() function", logger.E(errors.WithStack(err))) return nil } return errors.WithStack(err) } return nil } func LifecycleModuleFactory() app.ServerModuleFactory { return func(server *app.Server) app.ServerModule { module := &LifecycleModule{ server: server, } return module } } var _ app.InitializableModule = &LifecycleModule{}