@@ -124,31 +124,58 @@ class AdminForth implements IAdminForth {
124
124
}
125
125
126
126
constructor ( config : AdminForthInputConfig ) {
127
+ process . env . HEAVY_DEBUG && console . log ( '🔧 AdminForth constructor started' ) ;
128
+
127
129
if ( global . adminforth ) {
128
130
throw new Error ( 'AdminForth instance already created in this process. ' +
129
131
'If you want to use multiple instances, consider using different process for each instance' ) ;
130
132
}
133
+
134
+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating CodeInjector...' ) ;
131
135
this . codeInjector = new CodeInjector ( this ) ;
136
+ process . env . HEAVY_DEBUG && console . log ( '🔧 CodeInjector created' ) ;
137
+
138
+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating ConfigValidator...' ) ;
132
139
this . configValidator = new ConfigValidator ( this , config ) ;
140
+ process . env . HEAVY_DEBUG && console . log ( '🔧 ConfigValidator created' ) ;
141
+
142
+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating AdminForthRestAPI...' ) ;
133
143
this . restApi = new AdminForthRestAPI ( this ) ;
144
+ process . env . HEAVY_DEBUG && console . log ( '🔧 AdminForthRestAPI created' ) ;
145
+
146
+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating SocketBroker...' ) ;
134
147
this . websocket = new SocketBroker ( this ) ;
148
+ process . env . HEAVY_DEBUG && console . log ( '🔧 SocketBroker created' ) ;
149
+
135
150
this . activatedPlugins = [ ] ;
136
151
152
+ process . env . HEAVY_DEBUG && console . log ( '🔧 Validating config...' ) ;
137
153
this . configValidator . validateConfig ( ) ;
154
+ process . env . HEAVY_DEBUG && console . log ( '🔧 Config validated' ) ;
155
+
156
+ process . env . HEAVY_DEBUG && console . log ( '🔧 Activating plugins...' ) ;
138
157
this . activatePlugins ( ) ;
158
+ process . env . HEAVY_DEBUG && console . log ( '🔧 Plugins activated' ) ;
139
159
160
+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating ExpressServer...' ) ;
140
161
this . express = new ExpressServer ( this ) ;
162
+ process . env . HEAVY_DEBUG && console . log ( '🔧 ExpressServer created' ) ;
163
+
141
164
// this.fastify = new FastifyServer(this);
165
+ process . env . HEAVY_DEBUG && console . log ( '🔧 Creating AdminForthAuth...' ) ;
142
166
this . auth = new AdminForthAuth ( this ) ;
167
+ process . env . HEAVY_DEBUG && console . log ( '🔧 AdminForthAuth created' ) ;
168
+
143
169
this . connectors = { } ;
144
170
this . statuses = {
145
171
dbDiscover : 'running' ,
146
172
} ;
147
173
148
-
149
-
150
174
console . log ( `${ this . formatAdminForth ( ) } v${ ADMINFORTH_VERSION } initializing...` ) ;
175
+ process . env . HEAVY_DEBUG && console . log ( '🔧 About to set global.adminforth...' ) ;
151
176
global . adminforth = this ;
177
+ process . env . HEAVY_DEBUG && console . log ( '🔧 global.adminforth set successfully' ) ;
178
+ process . env . HEAVY_DEBUG && console . log ( '🔧 AdminForth constructor completed' ) ;
152
179
}
153
180
154
181
formatAdminForth ( ) {
@@ -174,14 +201,21 @@ class AdminForth implements IAdminForth {
174
201
process . env . HEAVY_DEBUG && console . log ( '🔌🔌🔌 Activating plugins' ) ;
175
202
const allPluginInstances = [ ] ;
176
203
for ( let resource of this . config . resources ) {
204
+ process . env . HEAVY_DEBUG && console . log ( `🔌 Checking plugins for resource: ${ resource . resourceId } ` ) ;
177
205
for ( let pluginInstance of resource . plugins || [ ] ) {
206
+ process . env . HEAVY_DEBUG && console . log ( `🔌 Found plugin: ${ pluginInstance . constructor . name } for resource ${ resource . resourceId } ` ) ;
178
207
allPluginInstances . push ( { pi : pluginInstance , resource} ) ;
179
208
}
180
209
}
210
+ process . env . HEAVY_DEBUG && console . log ( `🔌 Total plugins to activate: ${ allPluginInstances . length } ` ) ;
181
211
allPluginInstances . sort ( ( { pi : a } , { pi : b } ) => a . activationOrder - b . activationOrder ) ;
212
+
182
213
allPluginInstances . forEach (
183
- ( { pi : pluginInstance , resource} ) => {
214
+ ( { pi : pluginInstance , resource} , index ) => {
215
+ process . env . HEAVY_DEBUG && console . log ( `🔌 Activating plugin ${ index + 1 } /${ allPluginInstances . length } : ${ pluginInstance . constructor . name } for resource ${ resource . resourceId } ` ) ;
184
216
pluginInstance . modifyResourceConfig ( this , resource ) ;
217
+ process . env . HEAVY_DEBUG && console . log ( `🔌 Plugin ${ pluginInstance . constructor . name } modifyResourceConfig completed` ) ;
218
+
185
219
const plugin = this . activatedPlugins . find ( ( p ) => p . pluginInstanceId === pluginInstance . pluginInstanceId ) ;
186
220
if ( plugin ) {
187
221
process . env . HEAVY_DEBUG && console . log ( `Current plugin pluginInstance.pluginInstanceId ${ pluginInstance . pluginInstanceId } ` ) ;
@@ -190,8 +224,10 @@ class AdminForth implements IAdminForth {
190
224
To support multiple plugin instance pre one resource, plugin should return unique string values for each installation from instanceUniqueRepresentation` ) ;
191
225
}
192
226
this . activatedPlugins . push ( pluginInstance ) ;
227
+ process . env . HEAVY_DEBUG && console . log ( `🔌 Plugin ${ pluginInstance . constructor . name } activated successfully` ) ;
193
228
}
194
229
) ;
230
+ process . env . HEAVY_DEBUG && console . log ( '🔌 All plugins activation completed' ) ;
195
231
}
196
232
197
233
getPluginsByClassName < T > ( className : string ) : T [ ] {
0 commit comments