@futdevpro/nts-dynamo 1.6.58 → 1.6.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_constants/mocks/app-extended-server.mock.js +8 -13
- package/lib/_constants/mocks/app-extended-server.mock.js.map +1 -1
- package/lib/_constants/mocks/app-server.mock.js +4 -9
- package/lib/_constants/mocks/app-server.mock.js.map +1 -1
- package/lib/_constants/mocks/auth-service.mock.js +3 -10
- package/lib/_constants/mocks/auth-service.mock.js.map +1 -1
- package/lib/_constants/mocks/data-model.mock.js +17 -0
- package/lib/_constants/mocks/data-model.mock.js.map +1 -1
- package/lib/_constants/mocks/email-service-collection.mock.js +1 -4
- package/lib/_constants/mocks/email-service-collection.mock.js.map +1 -1
- package/lib/_constants/mocks/endpoint.mock.js +12 -13
- package/lib/_constants/mocks/endpoint.mock.js.map +1 -1
- package/lib/_constants/mocks/socket-client.mock.js +2 -3
- package/lib/_constants/mocks/socket-client.mock.js.map +1 -1
- package/lib/_constants/mocks/socket-server.mock.js +2 -5
- package/lib/_constants/mocks/socket-server.mock.js.map +1 -1
- package/lib/_enums/http/socket-event-type.enum.d.ts +1 -0
- package/lib/_enums/http/socket-event-type.enum.d.ts.map +1 -1
- package/lib/_enums/http/socket-event-type.enum.js +1 -0
- package/lib/_enums/http/socket-event-type.enum.js.map +1 -1
- package/lib/_models/control-models/api-call-params.control-model.js +32 -0
- package/lib/_models/control-models/api-call-params.control-model.js.map +1 -1
- package/lib/_models/control-models/app-params.control-model.js +31 -4
- package/lib/_models/control-models/app-params.control-model.js.map +1 -1
- package/lib/_models/control-models/app-system-controls.control-model copy.js +3 -5
- package/lib/_models/control-models/app-system-controls.control-model copy.js.map +1 -1
- package/lib/_models/control-models/app-system-controls.control-model.js +4 -6
- package/lib/_models/control-models/app-system-controls.control-model.js.map +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.js +91 -88
- package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-client-service-params.control-model.js +8 -5
- package/lib/_models/control-models/socket-client-service-params.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-event.control-model.js +35 -34
- package/lib/_models/control-models/socket-event.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-presence.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/socket-presence.control-model.js +14 -11
- package/lib/_models/control-models/socket-presence.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-server-service-params.control-model.js +3 -0
- package/lib/_models/control-models/socket-server-service-params.control-model.js.map +1 -1
- package/lib/_models/control-models/system-control.control-model.js +3 -5
- package/lib/_models/control-models/system-control.control-model.js.map +1 -1
- package/lib/_modules/custom-data/custom-data.controller.js +6 -7
- package/lib/_modules/custom-data/custom-data.controller.js.map +1 -1
- package/lib/_modules/test/test.controller.js +12 -13
- package/lib/_modules/test/test.controller.js.map +1 -1
- package/lib/_modules/usage/usage.controller.js +15 -14
- package/lib/_modules/usage/usage.controller.js.map +1 -1
- package/lib/_modules/usage/usage.data-service.js +88 -96
- package/lib/_modules/usage/usage.data-service.js.map +1 -1
- package/lib/_services/base/data.service.d.ts +2 -0
- package/lib/_services/base/data.service.d.ts.map +1 -1
- package/lib/_services/base/data.service.js +376 -253
- package/lib/_services/base/data.service.js.map +1 -1
- package/lib/_services/base/db.service.d.ts +1 -0
- package/lib/_services/base/db.service.d.ts.map +1 -1
- package/lib/_services/base/db.service.js +321 -247
- package/lib/_services/base/db.service.js.map +1 -1
- package/lib/_services/base/singleton.service.js +2 -0
- package/lib/_services/base/singleton.service.js.map +1 -1
- package/lib/_services/core/api.service.js +185 -188
- package/lib/_services/core/api.service.js.map +1 -1
- package/lib/_services/core/auth.service.js +3 -3
- package/lib/_services/core/auth.service.js.map +1 -1
- package/lib/_services/core/email.service.js +103 -88
- package/lib/_services/core/email.service.js.map +1 -1
- package/lib/_services/core/global.service.d.ts +1 -1
- package/lib/_services/core/global.service.d.ts.map +1 -1
- package/lib/_services/core/global.service.js +41 -41
- package/lib/_services/core/global.service.js.map +1 -1
- package/lib/_services/route/controller.service.js +28 -0
- package/lib/_services/route/controller.service.js.map +1 -1
- package/lib/_services/route/routing-module.service.js +11 -8
- package/lib/_services/route/routing-module.service.js.map +1 -1
- package/lib/_services/server/app-extended.server.js +241 -247
- package/lib/_services/server/app-extended.server.js.map +1 -1
- package/lib/_services/server/app-extended.server.spec.js +18 -19
- package/lib/_services/server/app-extended.server.spec.js.map +1 -1
- package/lib/_services/server/app.server.d.ts +2 -1
- package/lib/_services/server/app.server.d.ts.map +1 -1
- package/lib/_services/server/app.server.js +413 -410
- package/lib/_services/server/app.server.js.map +1 -1
- package/lib/_services/server/app.server.spec.js +12 -13
- package/lib/_services/server/app.server.spec.js.map +1 -1
- package/lib/_services/shared.static-service.js +15 -17
- package/lib/_services/shared.static-service.js.map +1 -1
- package/lib/_services/socket/socket-client.service.js +134 -145
- package/lib/_services/socket/socket-client.service.js.map +1 -1
- package/lib/_services/socket/socket-server.service.js +294 -263
- package/lib/_services/socket/socket-server.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -21
- package/src/_enums/http/socket-event-type.enum.ts +2 -0
- package/src/_models/control-models/socket-presence.control-model.ts +8 -2
- package/src/_services/base/data.service.ts +79 -0
- package/src/_services/base/db.service.ts +47 -28
- package/src/_services/core/global.service.ts +4 -2
- package/src/_services/server/app-extended.server.ts +2 -2
- package/src/_services/server/app.server.ts +18 -4
- package/tsconfig.json +2 -2
|
@@ -169,490 +169,493 @@ const app_system_controls_control_model_1 = require("../../_models/control-model
|
|
|
169
169
|
*
|
|
170
170
|
*/
|
|
171
171
|
class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
172
|
+
systemControls = new app_system_controls_control_model_1.DynamoNTS_AppSystemControls();
|
|
172
173
|
get started() { return this.systemControls.app.started; }
|
|
173
174
|
get superStarted() { return this.systemControls.app.started; }
|
|
175
|
+
constructErrors = [];
|
|
174
176
|
get serverName() { return this.params.name; }
|
|
177
|
+
_params;
|
|
175
178
|
get params() { return this._params; }
|
|
179
|
+
mongoose = Mongoose;
|
|
180
|
+
_security;
|
|
176
181
|
get security() { return this._security; }
|
|
182
|
+
_ports;
|
|
177
183
|
get ports() { return this._ports; }
|
|
184
|
+
_cert;
|
|
178
185
|
get cert() { return this._cert; }
|
|
186
|
+
openExpress;
|
|
187
|
+
secureExpress;
|
|
188
|
+
httpsServer;
|
|
189
|
+
httpServer;
|
|
190
|
+
globalService;
|
|
191
|
+
_rootServices = [];
|
|
192
|
+
_routingModules = [];
|
|
193
|
+
/**
|
|
194
|
+
* setting this value to true, enables this service debug logs
|
|
195
|
+
*/
|
|
196
|
+
logSetup;
|
|
197
|
+
deepLog;
|
|
198
|
+
logFn;
|
|
179
199
|
constructor(extended) {
|
|
180
200
|
super();
|
|
181
|
-
this.systemControls = new app_system_controls_control_model_1.DynamoNTS_AppSystemControls();
|
|
182
|
-
this.constructErrors = [];
|
|
183
|
-
this.mongoose = Mongoose;
|
|
184
|
-
this._rootServices = [];
|
|
185
|
-
this._routingModules = [];
|
|
186
201
|
process.on('unhandledRejection', (reason, p) => {
|
|
187
202
|
fsm_dynamo_1.Dynamo_Log.highlightedError('Unhandled Rejection at: ', p, '\nRejection reason:', reason);
|
|
203
|
+
try {
|
|
204
|
+
global_service_1.DynamoNTS_GlobalService.globalErrorHandler?.(new fsm_dynamo_1.Dynamo_Error({
|
|
205
|
+
errorCode: 'NTS-AS0-BASE-UR',
|
|
206
|
+
message: 'Unhandled Rejection!',
|
|
207
|
+
error: new Error(p),
|
|
208
|
+
}));
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
fsm_dynamo_1.Dynamo_Log.error('getGlobalErrorHandler ERROR:', error);
|
|
212
|
+
}
|
|
188
213
|
});
|
|
189
214
|
this.asyncConstruct(extended).catch((error) => {
|
|
190
215
|
fsm_dynamo_1.Dynamo_Log.error(`\nApplication: ${this._params.name} start failed.\n`, error);
|
|
191
216
|
});
|
|
192
217
|
}
|
|
193
|
-
asyncConstruct(extended) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
218
|
+
async asyncConstruct(extended) {
|
|
219
|
+
if (this.logFn && this.deepLog)
|
|
220
|
+
console.log('\nfn:. asyncConstruct');
|
|
221
|
+
try {
|
|
222
|
+
this.systemControls.app.init = true;
|
|
223
|
+
this._params = this.getAppParams();
|
|
224
|
+
fsm_dynamo_1.dynamo_error_default.issuerSystem = this._params.systemName;
|
|
225
|
+
this.overrideDynamoNTSGlobalSettings?.();
|
|
226
|
+
this.logSetup = global_settings_const_1.dynamoNTS_globalSettings.logSetup;
|
|
227
|
+
this.globalService = global_service_1.DynamoNTS_GlobalService.getInstance();
|
|
228
|
+
global_service_1.DynamoNTS_GlobalService.setServices(this.getGlobalServiceCollection());
|
|
229
|
+
global_service_1.DynamoNTS_GlobalService.setParams(this.params);
|
|
230
|
+
global_service_1.DynamoNTS_GlobalService.setGlobalErrorHandler(this.getGlobalErrorHandler?.());
|
|
231
|
+
if (this.getPortSettings) {
|
|
232
|
+
this._ports = this.getPortSettings();
|
|
233
|
+
}
|
|
234
|
+
if (this.getCertificationSettings) {
|
|
235
|
+
this._cert = this.getCertificationSettings();
|
|
236
|
+
}
|
|
237
|
+
if (this.getRoutingModules) {
|
|
238
|
+
this._routingModules = this.getRoutingModules();
|
|
239
|
+
}
|
|
240
|
+
await this.createEntries?.();
|
|
241
|
+
console.log(`\n\n\nStarting ${this._params.name}... `);
|
|
242
|
+
await this.startDB();
|
|
243
|
+
this.setSecurity();
|
|
244
|
+
if (this._routingModules?.length) {
|
|
245
|
+
await this.initExpresses();
|
|
246
|
+
await this.startExpresses();
|
|
247
|
+
if (this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
248
|
+
await this.mountOpenRoutes();
|
|
216
249
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
yield this.startDB();
|
|
220
|
-
this.setSecurity();
|
|
221
|
-
if ((_d = this._routingModules) === null || _d === void 0 ? void 0 : _d.length) {
|
|
222
|
-
yield this.initExpresses();
|
|
223
|
-
yield this.startExpresses();
|
|
224
|
-
if (this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
225
|
-
yield this.mountOpenRoutes();
|
|
226
|
-
}
|
|
227
|
-
if (this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.open && this._cert) {
|
|
228
|
-
yield this.mountSecureRoutes();
|
|
229
|
-
}
|
|
230
|
-
if (this.logSetup) {
|
|
231
|
-
console.log(`\nRoutes mounted.... server using security: ${this._security}`);
|
|
232
|
-
}
|
|
250
|
+
if (this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.open && this._cert) {
|
|
251
|
+
await this.mountSecureRoutes();
|
|
233
252
|
}
|
|
234
|
-
if (this.
|
|
235
|
-
|
|
253
|
+
if (this.logSetup) {
|
|
254
|
+
console.log(`\nRoutes mounted.... server using security: ${this._security}`);
|
|
236
255
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
256
|
+
}
|
|
257
|
+
if (this.getRootServices) {
|
|
258
|
+
this._rootServices = await this.getRootServices();
|
|
259
|
+
}
|
|
260
|
+
await this.postProcess?.();
|
|
261
|
+
if (!extended) {
|
|
262
|
+
await this.ready();
|
|
263
|
+
if (this.params.title) {
|
|
264
|
+
console.log(this.params.title);
|
|
265
|
+
console.log(`Version: ${this.params.version}`);
|
|
245
266
|
}
|
|
267
|
+
fsm_dynamo_1.Dynamo_Log.H_success(`${this.params.name} started successfully.`);
|
|
246
268
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
this.constructErrors.push(error);
|
|
272
|
+
fsm_dynamo_1.Dynamo_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
|
|
273
|
+
throw new fsm_dynamo_1.Dynamo_Error({
|
|
274
|
+
errorCode: 'NTS-AS0-001',
|
|
275
|
+
error: error,
|
|
276
|
+
additionalContent: {
|
|
277
|
+
constructErrors: this.constructErrors,
|
|
278
|
+
systemControls: this.systemControls,
|
|
279
|
+
systemReadies: {
|
|
280
|
+
app: this.systemControls.app.getReady(),
|
|
281
|
+
mongoose: this.systemControls.mongoose.getReady(),
|
|
282
|
+
httpServer: this.systemControls.httpServer.getReady(),
|
|
283
|
+
httpsServer: this.systemControls.httpsServer.getReady(),
|
|
262
284
|
},
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
}
|
|
266
288
|
}
|
|
267
|
-
ready(timeout = 4 * fsm_dynamo_1.second) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
289
|
+
async ready(timeout = 4 * fsm_dynamo_1.second) {
|
|
290
|
+
if (this.logFn)
|
|
291
|
+
console.log('\nfn:. ready');
|
|
292
|
+
let ready = false;
|
|
293
|
+
const start = +new Date();
|
|
294
|
+
if (this.constructErrors.length) {
|
|
295
|
+
fsm_dynamo_1.Dynamo_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
|
|
296
|
+
throw new fsm_dynamo_1.Dynamo_Error({
|
|
297
|
+
message: `${this._params.name} start failed. ERRORS`,
|
|
298
|
+
additionalContent: this.constructErrors.length === 1 ? this.constructErrors[0] : { errors: this.constructErrors },
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
while (!ready && +new Date() - start < timeout) {
|
|
302
|
+
if (this.systemControls.app.init) {
|
|
303
|
+
ready = (this.systemControls.mongoose.getReady() &&
|
|
304
|
+
this.systemControls.httpServer.getReady() &&
|
|
305
|
+
this.systemControls.httpsServer.getReady());
|
|
280
306
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
fsm_dynamo_1.Dynamo_Log.error(`${this.params.name} APP NOT INITIALIZED while trying to get ready.`);
|
|
289
|
-
}
|
|
290
|
-
if (!ready) {
|
|
291
|
-
yield (0, fsm_dynamo_1.wait)(100);
|
|
292
|
-
}
|
|
307
|
+
else {
|
|
308
|
+
fsm_dynamo_1.Dynamo_Log.error(`${this.params.name} APP NOT INITIALIZED while trying to get ready.`);
|
|
309
|
+
}
|
|
310
|
+
if (!ready) {
|
|
311
|
+
await (0, fsm_dynamo_1.wait)(100);
|
|
293
312
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
313
|
+
}
|
|
314
|
+
if (timeout < +new Date() - start) {
|
|
315
|
+
fsm_dynamo_1.Dynamo_Log.error(`${this._params.name} start failed. TIMEOUT`, this.constructErrors);
|
|
316
|
+
throw new fsm_dynamo_1.Dynamo_Error({
|
|
317
|
+
message: `${this._params.name} start failed. TIMEOUT`,
|
|
318
|
+
additionalContent: {
|
|
319
|
+
constructErrors: this.constructErrors,
|
|
320
|
+
systemControls: this.systemControls,
|
|
321
|
+
systemReadies: {
|
|
322
|
+
mongoose: this.systemControls.mongoose.getReady(),
|
|
323
|
+
httpServer: this.systemControls.httpServer.getReady(),
|
|
324
|
+
httpsServer: this.systemControls.httpsServer.getReady(),
|
|
306
325
|
},
|
|
307
|
-
}
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
if (this.constructErrors.length) {
|
|
330
|
+
fsm_dynamo_1.Dynamo_Log.error(`${this._params.name} start failed. ERROR`, this.constructErrors);
|
|
331
|
+
throw new fsm_dynamo_1.Dynamo_Error({
|
|
332
|
+
message: `${this._params.name} start failed. ERROR`,
|
|
333
|
+
additionalContent: this.constructErrors,
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
if (ready) {
|
|
337
|
+
this.systemControls.app.started = true;
|
|
338
|
+
if (this.logFn && this.deepLog)
|
|
339
|
+
console.log('\nfn:. ready: return');
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
this.systemControls.app.started = false;
|
|
344
|
+
let msg = `${this._params.name} start failed. UNKNOWN`;
|
|
345
|
+
if (this.systemControls.mongoose.init && !this.systemControls.mongoose.started) {
|
|
346
|
+
msg += `\nMongoose start failed.`;
|
|
308
347
|
}
|
|
309
|
-
if (this.
|
|
310
|
-
|
|
311
|
-
throw new fsm_dynamo_1.Dynamo_Error({
|
|
312
|
-
message: `${this._params.name} start failed. ERROR`,
|
|
313
|
-
additionalContent: this.constructErrors,
|
|
314
|
-
});
|
|
348
|
+
if (this.systemControls.httpServer.init && !this.systemControls.httpServer.started) {
|
|
349
|
+
msg += `\nHTTP Server start failed.`;
|
|
315
350
|
}
|
|
316
|
-
if (
|
|
317
|
-
|
|
318
|
-
if (this.logFn && this.deepLog)
|
|
319
|
-
console.log('\nfn:. ready: return');
|
|
320
|
-
return;
|
|
351
|
+
if (this.systemControls.httpsServer.init && !this.systemControls.httpsServer.started) {
|
|
352
|
+
msg += `\nHTTPS Server start failed.`;
|
|
321
353
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
354
|
+
fsm_dynamo_1.Dynamo_Log.error(msg, this.constructErrors);
|
|
355
|
+
throw new fsm_dynamo_1.Dynamo_Error({
|
|
356
|
+
errorCode: 'NTS-AS0-110',
|
|
357
|
+
message: msg,
|
|
358
|
+
additionalContent: {
|
|
359
|
+
constructErrors: this.constructErrors,
|
|
360
|
+
systemControls: this.systemControls,
|
|
361
|
+
systemReadies: {
|
|
362
|
+
app: this.systemControls.app.getReady(),
|
|
363
|
+
mongoose: this.systemControls.mongoose.getReady(),
|
|
364
|
+
httpServer: this.systemControls.httpServer.getReady(),
|
|
365
|
+
httpsServer: this.systemControls.httpsServer.getReady(),
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
error: this.constructErrors?.[0] ?? new Error(),
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
async stop(dontLog) {
|
|
373
|
+
if (this.logFn)
|
|
374
|
+
console.log('\nfn:. stop');
|
|
375
|
+
if (this.started) {
|
|
376
|
+
if (this.systemControls.mongoose.init) {
|
|
377
|
+
this.systemControls.mongoose.started = false;
|
|
378
|
+
if (this.mongoose) {
|
|
379
|
+
await fsm_dynamo_1.Dynamo_Array.asyncForEach(Object.keys(this.mongoose.models), async (modelName) => {
|
|
380
|
+
await this.mongoose.deleteModel(modelName);
|
|
381
|
+
});
|
|
382
|
+
await this.mongoose.disconnect();
|
|
330
383
|
}
|
|
331
|
-
|
|
332
|
-
|
|
384
|
+
else {
|
|
385
|
+
fsm_dynamo_1.Dynamo_Log.error(`\nMongoose not found.`);
|
|
333
386
|
}
|
|
334
|
-
|
|
335
|
-
throw new fsm_dynamo_1.Dynamo_Error({
|
|
336
|
-
errorCode: 'NTS-AS0-110',
|
|
337
|
-
message: msg,
|
|
338
|
-
additionalContent: {
|
|
339
|
-
constructErrors: this.constructErrors,
|
|
340
|
-
systemControls: this.systemControls,
|
|
341
|
-
systemReadies: {
|
|
342
|
-
app: this.systemControls.app.getReady(),
|
|
343
|
-
mongoose: this.systemControls.mongoose.getReady(),
|
|
344
|
-
httpServer: this.systemControls.httpServer.getReady(),
|
|
345
|
-
httpsServer: this.systemControls.httpsServer.getReady(),
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
error: (_b = (_a = this.constructErrors) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : new Error(),
|
|
349
|
-
});
|
|
387
|
+
this.systemControls.mongoose.init = false;
|
|
350
388
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (this.started) {
|
|
358
|
-
if (this.systemControls.mongoose.init) {
|
|
359
|
-
this.systemControls.mongoose.started = false;
|
|
360
|
-
if (this.mongoose) {
|
|
361
|
-
yield fsm_dynamo_1.Dynamo_Array.asyncForEach(Object.keys(this.mongoose.models), (modelName) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
362
|
-
yield this.mongoose.deleteModel(modelName);
|
|
363
|
-
}));
|
|
364
|
-
yield this.mongoose.disconnect();
|
|
365
|
-
}
|
|
366
|
-
else {
|
|
367
|
-
fsm_dynamo_1.Dynamo_Log.error(`\nMongoose not found.`);
|
|
368
|
-
}
|
|
369
|
-
this.systemControls.mongoose.init = false;
|
|
389
|
+
if (this.systemControls.httpServer.init) {
|
|
390
|
+
this.systemControls.httpServer.started = false;
|
|
391
|
+
if (this.httpServer) {
|
|
392
|
+
await new Promise((resolve) => {
|
|
393
|
+
this.httpServer.close(resolve);
|
|
394
|
+
});
|
|
370
395
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if (this.httpServer) {
|
|
374
|
-
yield new Promise((resolve) => {
|
|
375
|
-
this.httpServer.close(resolve);
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
else {
|
|
379
|
-
fsm_dynamo_1.Dynamo_Log.error(`\nHTTP Server not found.`);
|
|
380
|
-
}
|
|
381
|
-
this.systemControls.httpServer.init = false;
|
|
396
|
+
else {
|
|
397
|
+
fsm_dynamo_1.Dynamo_Log.error(`\nHTTP Server not found.`);
|
|
382
398
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
fsm_dynamo_1.Dynamo_Log.error(`\nHTTPS Server not found.`);
|
|
392
|
-
}
|
|
393
|
-
this.systemControls.httpsServer.init = false;
|
|
399
|
+
this.systemControls.httpServer.init = false;
|
|
400
|
+
}
|
|
401
|
+
if (this.systemControls.httpsServer.init) {
|
|
402
|
+
this.systemControls.httpsServer.started = false;
|
|
403
|
+
if (this.httpsServer) {
|
|
404
|
+
await new Promise((resolve) => {
|
|
405
|
+
this.httpsServer.close(resolve);
|
|
406
|
+
});
|
|
394
407
|
}
|
|
395
|
-
|
|
396
|
-
fsm_dynamo_1.Dynamo_Log.
|
|
408
|
+
else {
|
|
409
|
+
fsm_dynamo_1.Dynamo_Log.error(`\nHTTPS Server not found.`);
|
|
397
410
|
}
|
|
411
|
+
this.systemControls.httpsServer.init = false;
|
|
398
412
|
}
|
|
399
|
-
|
|
413
|
+
if (!dontLog) {
|
|
414
|
+
fsm_dynamo_1.Dynamo_Log.H_log(`${this._params.name} stopped successfully.`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
400
417
|
}
|
|
401
418
|
/**
|
|
402
419
|
*
|
|
403
420
|
*/
|
|
404
|
-
startDB() {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
});
|
|
430
|
-
}));
|
|
421
|
+
async startDB() {
|
|
422
|
+
if (this.logFn && this.deepLog)
|
|
423
|
+
console.log('\nfn:. startDB');
|
|
424
|
+
await new Promise(async (resolve, reject) => {
|
|
425
|
+
this.systemControls.mongoose.init = true;
|
|
426
|
+
this.mongoose.connection
|
|
427
|
+
.on('error', (error) => {
|
|
428
|
+
this.systemControls.mongoose.started = false;
|
|
429
|
+
this.constructErrors.push(error);
|
|
430
|
+
fsm_dynamo_1.Dynamo_Log.error('\nUnable to connect to MongoDB server, ERROR: ', error);
|
|
431
|
+
reject(new fsm_dynamo_1.Dynamo_Error({
|
|
432
|
+
errorCode: 'NTS-AS0-100',
|
|
433
|
+
message: `Unable to connect to MongoDB server, ERROR: ${error}`,
|
|
434
|
+
error: error,
|
|
435
|
+
}));
|
|
436
|
+
})
|
|
437
|
+
.once('open', () => {
|
|
438
|
+
this.systemControls.mongoose.started = true;
|
|
439
|
+
fsm_dynamo_1.Dynamo_Log.success('\nConnected to MongoDB\n');
|
|
440
|
+
resolve();
|
|
441
|
+
});
|
|
442
|
+
this.mongoose.connect(this._params.dbUri, {
|
|
443
|
+
useNewUrlParser: true,
|
|
444
|
+
useUnifiedTopology: true
|
|
445
|
+
});
|
|
431
446
|
});
|
|
432
447
|
}
|
|
433
448
|
/**
|
|
434
449
|
*
|
|
435
450
|
*/
|
|
436
|
-
initExpresses() {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
if (this.
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
throw error;
|
|
462
|
-
}
|
|
463
|
-
yield this.initOpenExpress();
|
|
451
|
+
async initExpresses() {
|
|
452
|
+
if (this.logFn && this.deepLog)
|
|
453
|
+
console.log('\nfn:. initExpresses');
|
|
454
|
+
if (this._security && this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
455
|
+
if (!this._ports.httpPort) {
|
|
456
|
+
let errorMsg = `\nYou have open routes, but httpPort is not set!` +
|
|
457
|
+
`\nsecurity: ${this._security}` +
|
|
458
|
+
`\nset httpPort in DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
459
|
+
errorMsg += '\n\nThe routes setted to use open server:';
|
|
460
|
+
this._routingModules.forEach((module) => {
|
|
461
|
+
if (module.security != route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
462
|
+
errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using open sever:`;
|
|
463
|
+
module.endpoints.forEach((endpoint) => {
|
|
464
|
+
if (endpoint.security != route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
465
|
+
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
let error = new Error('Open routes cannot be established!');
|
|
471
|
+
let errorStack = error.stack.split('\n');
|
|
472
|
+
errorStack.splice(1, 2);
|
|
473
|
+
error.stack = errorStack.join('\n');
|
|
474
|
+
fsm_dynamo_1.Dynamo_Log.error(errorMsg);
|
|
475
|
+
throw error;
|
|
464
476
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
477
|
+
await this.initOpenExpress();
|
|
478
|
+
}
|
|
479
|
+
if (this._security && this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
480
|
+
if (!this._cert || !this._ports.httpsPort) {
|
|
481
|
+
let errorMsg = `\nYou have secure routes, but the certification paths or httpsPort are not set!` +
|
|
482
|
+
`\nsecurity: ${this._security}` +
|
|
483
|
+
`\nset...` +
|
|
484
|
+
`\n httpsPort and` +
|
|
485
|
+
`\n cert: {` +
|
|
486
|
+
`\n keyPath: FileSystem.PathLike,` +
|
|
487
|
+
`\n certPath: FileSystem.PathLike,` +
|
|
488
|
+
`\n }` +
|
|
489
|
+
`\nin DynamoBEServer - getRoutingModules() to enable secure routes.`;
|
|
490
|
+
errorMsg += '\n\nThe routes setted to use secure server:';
|
|
491
|
+
this._routingModules.forEach((module) => {
|
|
492
|
+
if (module.security && module.security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
493
|
+
errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using secure sever:`;
|
|
494
|
+
module.endpoints.forEach((endpoint) => {
|
|
495
|
+
if (endpoint.security && endpoint.security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
496
|
+
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
let error = new Error('Secure routes cannot be established!');
|
|
502
|
+
let errorStack = error.stack.split('\n');
|
|
503
|
+
errorStack.splice(1, 2);
|
|
504
|
+
error.stack = errorStack.join('\n');
|
|
505
|
+
fsm_dynamo_1.Dynamo_Log.error(errorMsg);
|
|
506
|
+
throw error;
|
|
495
507
|
}
|
|
496
|
-
|
|
508
|
+
await this.initSecureExpress();
|
|
509
|
+
}
|
|
497
510
|
}
|
|
498
511
|
/**
|
|
499
512
|
*
|
|
500
513
|
*/
|
|
501
|
-
initOpenExpress() {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
this.openExpress.use(BodyParser.json({ limit: '50mb' }));
|
|
508
|
-
});
|
|
514
|
+
async initOpenExpress() {
|
|
515
|
+
if (this.logFn)
|
|
516
|
+
console.log('\nfn:. initOpenExpress');
|
|
517
|
+
this.openExpress = Express();
|
|
518
|
+
this.openExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
|
|
519
|
+
this.openExpress.use(BodyParser.json({ limit: '50mb' }));
|
|
509
520
|
}
|
|
510
521
|
/**
|
|
511
522
|
*
|
|
512
523
|
*/
|
|
513
|
-
initSecureExpress() {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
this.httpsServer = Https.createServer(options, this.secureExpress);
|
|
525
|
-
});
|
|
524
|
+
async initSecureExpress() {
|
|
525
|
+
if (this.logFn)
|
|
526
|
+
console.log('\nfn:. initSecureExpress');
|
|
527
|
+
this.secureExpress = Express();
|
|
528
|
+
this.secureExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
|
|
529
|
+
this.secureExpress.use(BodyParser.json({ limit: '50mb' }));
|
|
530
|
+
const options = {
|
|
531
|
+
key: FileSystem.readFileSync(this._cert.keyPath),
|
|
532
|
+
cert: FileSystem.readFileSync(this._cert.certPath),
|
|
533
|
+
};
|
|
534
|
+
this.httpsServer = Https.createServer(options, this.secureExpress);
|
|
526
535
|
}
|
|
527
536
|
/**
|
|
528
537
|
*
|
|
529
538
|
*/
|
|
530
|
-
startExpresses() {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
this.
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}));
|
|
560
|
-
});
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
if (this._security && this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
564
|
-
this.systemControls.httpServer.init = true;
|
|
565
|
-
yield new Promise((resolve, reject) => {
|
|
566
|
-
this.httpServer = this.openExpress
|
|
567
|
-
.listen(this._ports.httpPort, () => {
|
|
568
|
-
this.systemControls.httpServer.started = true;
|
|
569
|
-
fsm_dynamo_1.Dynamo_Log.success(`\nHTTP (open) server is listening on port: ${this._ports.httpPort}`);
|
|
570
|
-
resolve();
|
|
571
|
-
})
|
|
572
|
-
.on('error', (error) => {
|
|
573
|
-
this.systemControls.httpServer.started = false;
|
|
574
|
-
this.constructErrors.push(error);
|
|
575
|
-
fsm_dynamo_1.Dynamo_Log.error(`\nHTTP (open) server ERROR`, error);
|
|
576
|
-
reject(new fsm_dynamo_1.Dynamo_Error({
|
|
577
|
-
errorCode: 'NTS-AS0-003',
|
|
578
|
-
message: `HTTP (open) server ERROR`,
|
|
579
|
-
error: error,
|
|
580
|
-
}));
|
|
581
|
-
})
|
|
582
|
-
.on('uncaughtException', (ex) => {
|
|
583
|
-
fsm_dynamo_1.Dynamo_Log.warn(`\nHTTP (open) server uncaughtException`, new fsm_dynamo_1.Dynamo_Error({
|
|
584
|
-
errorCode: 'NTS-AS0-004',
|
|
585
|
-
message: `HTTP (open) server uncaughtException`,
|
|
586
|
-
error: ex
|
|
587
|
-
}));
|
|
588
|
-
});
|
|
539
|
+
async startExpresses() {
|
|
540
|
+
if (this.logFn && this.deepLog)
|
|
541
|
+
console.log('\nfn:. startExpresses');
|
|
542
|
+
try {
|
|
543
|
+
if (this._security && this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
544
|
+
await new Promise((resolve, reject) => {
|
|
545
|
+
this.systemControls.httpsServer.init = true;
|
|
546
|
+
this.httpsServer
|
|
547
|
+
.listen(this._ports.httpsPort, 'localhost', 0, () => {
|
|
548
|
+
this.systemControls.httpsServer.started = true;
|
|
549
|
+
fsm_dynamo_1.Dynamo_Log.success(`\nHTTPS (secure) server is listening on port: ${this._ports.httpsPort}`);
|
|
550
|
+
resolve();
|
|
551
|
+
})
|
|
552
|
+
.on('error', (error) => {
|
|
553
|
+
this.systemControls.httpsServer.started = false;
|
|
554
|
+
this.constructErrors.push(error);
|
|
555
|
+
fsm_dynamo_1.Dynamo_Log.error(`\nHTTPS (secure) server ERROR`, error);
|
|
556
|
+
reject(new fsm_dynamo_1.Dynamo_Error({
|
|
557
|
+
errorCode: 'NTS-AS0-001',
|
|
558
|
+
message: `HTTPS (secure) server ERROR`,
|
|
559
|
+
error: error,
|
|
560
|
+
}));
|
|
561
|
+
})
|
|
562
|
+
.on('uncaughtException', (ex) => {
|
|
563
|
+
fsm_dynamo_1.Dynamo_Log.warn(`\nHTTPS (secure) server uncaughtException`, new fsm_dynamo_1.Dynamo_Error({
|
|
564
|
+
errorCode: 'NTS-AS0-002',
|
|
565
|
+
message: `HTTPS (secure) server uncaughtException`,
|
|
566
|
+
error: ex,
|
|
567
|
+
}));
|
|
589
568
|
});
|
|
590
|
-
}
|
|
569
|
+
});
|
|
591
570
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
571
|
+
if (this._security && this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
572
|
+
this.systemControls.httpServer.init = true;
|
|
573
|
+
await new Promise((resolve, reject) => {
|
|
574
|
+
this.httpServer = this.openExpress
|
|
575
|
+
.listen(this._ports.httpPort, () => {
|
|
576
|
+
this.systemControls.httpServer.started = true;
|
|
577
|
+
fsm_dynamo_1.Dynamo_Log.success(`\nHTTP (open) server is listening on port: ${this._ports.httpPort}`);
|
|
578
|
+
resolve();
|
|
579
|
+
})
|
|
580
|
+
.on('error', (error) => {
|
|
581
|
+
this.systemControls.httpServer.started = false;
|
|
582
|
+
this.constructErrors.push(error);
|
|
583
|
+
fsm_dynamo_1.Dynamo_Log.error(`\nHTTP (open) server ERROR`, error);
|
|
584
|
+
reject(new fsm_dynamo_1.Dynamo_Error({
|
|
585
|
+
errorCode: 'NTS-AS0-003',
|
|
586
|
+
message: `HTTP (open) server ERROR`,
|
|
587
|
+
error: error,
|
|
588
|
+
}));
|
|
589
|
+
})
|
|
590
|
+
.on('uncaughtException', (ex) => {
|
|
591
|
+
fsm_dynamo_1.Dynamo_Log.warn(`\nHTTP (open) server uncaughtException`, new fsm_dynamo_1.Dynamo_Error({
|
|
592
|
+
errorCode: 'NTS-AS0-004',
|
|
593
|
+
message: `HTTP (open) server uncaughtException`,
|
|
594
|
+
error: ex
|
|
595
|
+
}));
|
|
596
|
+
});
|
|
597
|
+
});
|
|
595
598
|
}
|
|
596
|
-
}
|
|
599
|
+
}
|
|
600
|
+
catch (error) {
|
|
601
|
+
fsm_dynamo_1.Dynamo_Log.error(`startExpresses failed...`, error);
|
|
602
|
+
throw error;
|
|
603
|
+
}
|
|
597
604
|
}
|
|
598
605
|
/**
|
|
599
606
|
*
|
|
600
607
|
*/
|
|
601
|
-
mountSecureRoutes() {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
if (
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
this.secureExpress.use(module.route, module.secureRouter);
|
|
608
|
+
async mountSecureRoutes() {
|
|
609
|
+
if (this.logFn && this.deepLog)
|
|
610
|
+
console.log('\nfn:. mountSecureRoutes');
|
|
611
|
+
await fsm_dynamo_1.Dynamo_Array.asyncForEach(this._routingModules, async (module) => {
|
|
612
|
+
if (module.security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
613
|
+
if (this.logSetup) {
|
|
614
|
+
console.log(`route mount (secure): ${module.route}`);
|
|
615
|
+
}
|
|
616
|
+
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
617
|
+
if (1 < existingRoutes.length) {
|
|
618
|
+
let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
619
|
+
let errorStack = error.stack.split('\n');
|
|
620
|
+
errorStack.splice(1, 4);
|
|
621
|
+
error.stack = errorStack.join('\n');
|
|
622
|
+
fsm_dynamo_1.Dynamo_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
623
|
+
throw new fsm_dynamo_1.Dynamo_Error({
|
|
624
|
+
errorCode: 'NTS-AS0-005',
|
|
625
|
+
message: `ROUTE DUPLICATION: ${module.route}`,
|
|
626
|
+
error: error,
|
|
627
|
+
});
|
|
624
628
|
}
|
|
625
|
-
|
|
629
|
+
this.secureExpress.use(module.route, module.secureRouter);
|
|
630
|
+
}
|
|
626
631
|
});
|
|
627
632
|
}
|
|
628
633
|
/**
|
|
629
634
|
*
|
|
630
635
|
*/
|
|
631
|
-
mountOpenRoutes() {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
if (
|
|
637
|
-
|
|
638
|
-
console.log(`route mount (open): ${module.route}`);
|
|
639
|
-
}
|
|
640
|
-
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
641
|
-
if (1 < existingRoutes.length) {
|
|
642
|
-
let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
643
|
-
let errorStack = error.stack.split('\n');
|
|
644
|
-
errorStack.splice(1, 4);
|
|
645
|
-
error.stack = errorStack.join('\n');
|
|
646
|
-
fsm_dynamo_1.Dynamo_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
647
|
-
throw new fsm_dynamo_1.Dynamo_Error({
|
|
648
|
-
errorCode: 'NTS-AS0-006',
|
|
649
|
-
message: `ROUTE DUPLICATION: ${module.route}`,
|
|
650
|
-
error: error,
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
this.openExpress.use(module.route, module.openRouter);
|
|
636
|
+
async mountOpenRoutes() {
|
|
637
|
+
if (this.logFn && this.deepLog)
|
|
638
|
+
console.log('\nfn:. mountOpenRoutes');
|
|
639
|
+
await fsm_dynamo_1.Dynamo_Array.asyncForEach(this._routingModules, async (module) => {
|
|
640
|
+
if (module.security !== route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
641
|
+
if (this.logSetup) {
|
|
642
|
+
console.log(`route mount (open): ${module.route}`);
|
|
654
643
|
}
|
|
655
|
-
|
|
644
|
+
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
645
|
+
if (1 < existingRoutes.length) {
|
|
646
|
+
let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
|
|
647
|
+
let errorStack = error.stack.split('\n');
|
|
648
|
+
errorStack.splice(1, 4);
|
|
649
|
+
error.stack = errorStack.join('\n');
|
|
650
|
+
fsm_dynamo_1.Dynamo_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
651
|
+
throw new fsm_dynamo_1.Dynamo_Error({
|
|
652
|
+
errorCode: 'NTS-AS0-006',
|
|
653
|
+
message: `ROUTE DUPLICATION: ${module.route}`,
|
|
654
|
+
error: error,
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
this.openExpress.use(module.route, module.openRouter);
|
|
658
|
+
}
|
|
656
659
|
});
|
|
657
660
|
}
|
|
658
661
|
/**
|