@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.
Files changed (99) hide show
  1. package/lib/_constants/mocks/app-extended-server.mock.js +8 -13
  2. package/lib/_constants/mocks/app-extended-server.mock.js.map +1 -1
  3. package/lib/_constants/mocks/app-server.mock.js +4 -9
  4. package/lib/_constants/mocks/app-server.mock.js.map +1 -1
  5. package/lib/_constants/mocks/auth-service.mock.js +3 -10
  6. package/lib/_constants/mocks/auth-service.mock.js.map +1 -1
  7. package/lib/_constants/mocks/data-model.mock.js +17 -0
  8. package/lib/_constants/mocks/data-model.mock.js.map +1 -1
  9. package/lib/_constants/mocks/email-service-collection.mock.js +1 -4
  10. package/lib/_constants/mocks/email-service-collection.mock.js.map +1 -1
  11. package/lib/_constants/mocks/endpoint.mock.js +12 -13
  12. package/lib/_constants/mocks/endpoint.mock.js.map +1 -1
  13. package/lib/_constants/mocks/socket-client.mock.js +2 -3
  14. package/lib/_constants/mocks/socket-client.mock.js.map +1 -1
  15. package/lib/_constants/mocks/socket-server.mock.js +2 -5
  16. package/lib/_constants/mocks/socket-server.mock.js.map +1 -1
  17. package/lib/_enums/http/socket-event-type.enum.d.ts +1 -0
  18. package/lib/_enums/http/socket-event-type.enum.d.ts.map +1 -1
  19. package/lib/_enums/http/socket-event-type.enum.js +1 -0
  20. package/lib/_enums/http/socket-event-type.enum.js.map +1 -1
  21. package/lib/_models/control-models/api-call-params.control-model.js +32 -0
  22. package/lib/_models/control-models/api-call-params.control-model.js.map +1 -1
  23. package/lib/_models/control-models/app-params.control-model.js +31 -4
  24. package/lib/_models/control-models/app-params.control-model.js.map +1 -1
  25. package/lib/_models/control-models/app-system-controls.control-model copy.js +3 -5
  26. package/lib/_models/control-models/app-system-controls.control-model copy.js.map +1 -1
  27. package/lib/_models/control-models/app-system-controls.control-model.js +4 -6
  28. package/lib/_models/control-models/app-system-controls.control-model.js.map +1 -1
  29. package/lib/_models/control-models/endpoint-params.control-model.js +91 -88
  30. package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
  31. package/lib/_models/control-models/socket-client-service-params.control-model.js +8 -5
  32. package/lib/_models/control-models/socket-client-service-params.control-model.js.map +1 -1
  33. package/lib/_models/control-models/socket-event.control-model.js +35 -34
  34. package/lib/_models/control-models/socket-event.control-model.js.map +1 -1
  35. package/lib/_models/control-models/socket-presence.control-model.d.ts.map +1 -1
  36. package/lib/_models/control-models/socket-presence.control-model.js +14 -11
  37. package/lib/_models/control-models/socket-presence.control-model.js.map +1 -1
  38. package/lib/_models/control-models/socket-server-service-params.control-model.js +3 -0
  39. package/lib/_models/control-models/socket-server-service-params.control-model.js.map +1 -1
  40. package/lib/_models/control-models/system-control.control-model.js +3 -5
  41. package/lib/_models/control-models/system-control.control-model.js.map +1 -1
  42. package/lib/_modules/custom-data/custom-data.controller.js +6 -7
  43. package/lib/_modules/custom-data/custom-data.controller.js.map +1 -1
  44. package/lib/_modules/test/test.controller.js +12 -13
  45. package/lib/_modules/test/test.controller.js.map +1 -1
  46. package/lib/_modules/usage/usage.controller.js +15 -14
  47. package/lib/_modules/usage/usage.controller.js.map +1 -1
  48. package/lib/_modules/usage/usage.data-service.js +88 -96
  49. package/lib/_modules/usage/usage.data-service.js.map +1 -1
  50. package/lib/_services/base/data.service.d.ts +2 -0
  51. package/lib/_services/base/data.service.d.ts.map +1 -1
  52. package/lib/_services/base/data.service.js +376 -253
  53. package/lib/_services/base/data.service.js.map +1 -1
  54. package/lib/_services/base/db.service.d.ts +1 -0
  55. package/lib/_services/base/db.service.d.ts.map +1 -1
  56. package/lib/_services/base/db.service.js +321 -247
  57. package/lib/_services/base/db.service.js.map +1 -1
  58. package/lib/_services/base/singleton.service.js +2 -0
  59. package/lib/_services/base/singleton.service.js.map +1 -1
  60. package/lib/_services/core/api.service.js +185 -188
  61. package/lib/_services/core/api.service.js.map +1 -1
  62. package/lib/_services/core/auth.service.js +3 -3
  63. package/lib/_services/core/auth.service.js.map +1 -1
  64. package/lib/_services/core/email.service.js +103 -88
  65. package/lib/_services/core/email.service.js.map +1 -1
  66. package/lib/_services/core/global.service.d.ts +1 -1
  67. package/lib/_services/core/global.service.d.ts.map +1 -1
  68. package/lib/_services/core/global.service.js +41 -41
  69. package/lib/_services/core/global.service.js.map +1 -1
  70. package/lib/_services/route/controller.service.js +28 -0
  71. package/lib/_services/route/controller.service.js.map +1 -1
  72. package/lib/_services/route/routing-module.service.js +11 -8
  73. package/lib/_services/route/routing-module.service.js.map +1 -1
  74. package/lib/_services/server/app-extended.server.js +241 -247
  75. package/lib/_services/server/app-extended.server.js.map +1 -1
  76. package/lib/_services/server/app-extended.server.spec.js +18 -19
  77. package/lib/_services/server/app-extended.server.spec.js.map +1 -1
  78. package/lib/_services/server/app.server.d.ts +2 -1
  79. package/lib/_services/server/app.server.d.ts.map +1 -1
  80. package/lib/_services/server/app.server.js +413 -410
  81. package/lib/_services/server/app.server.js.map +1 -1
  82. package/lib/_services/server/app.server.spec.js +12 -13
  83. package/lib/_services/server/app.server.spec.js.map +1 -1
  84. package/lib/_services/shared.static-service.js +15 -17
  85. package/lib/_services/shared.static-service.js.map +1 -1
  86. package/lib/_services/socket/socket-client.service.js +134 -145
  87. package/lib/_services/socket/socket-client.service.js.map +1 -1
  88. package/lib/_services/socket/socket-server.service.js +294 -263
  89. package/lib/_services/socket/socket-server.service.js.map +1 -1
  90. package/lib/tsconfig.tsbuildinfo +1 -1
  91. package/package.json +19 -21
  92. package/src/_enums/http/socket-event-type.enum.ts +2 -0
  93. package/src/_models/control-models/socket-presence.control-model.ts +8 -2
  94. package/src/_services/base/data.service.ts +79 -0
  95. package/src/_services/base/db.service.ts +47 -28
  96. package/src/_services/core/global.service.ts +4 -2
  97. package/src/_services/server/app-extended.server.ts +2 -2
  98. package/src/_services/server/app.server.ts +18 -4
  99. 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
- var _a, _b, _c, _d, _e;
195
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
196
- if (this.logFn && this.deepLog)
197
- console.log('\nfn:. asyncConstruct');
198
- try {
199
- this.systemControls.app.init = true;
200
- this._params = this.getAppParams();
201
- fsm_dynamo_1.dynamo_error_default.issuerSystem = this._params.systemName;
202
- (_a = this.overrideDynamoNTSGlobalSettings) === null || _a === void 0 ? void 0 : _a.call(this);
203
- this.logSetup = global_settings_const_1.dynamoNTS_globalSettings.logSetup;
204
- this.globalService = global_service_1.DynamoNTS_GlobalService.getInstance();
205
- global_service_1.DynamoNTS_GlobalService.setServices(this.getGlobalServiceCollection());
206
- global_service_1.DynamoNTS_GlobalService.setParams(this.params);
207
- global_service_1.DynamoNTS_GlobalService.setGlobalErrorHandler((_b = this.getGlobalErrorHandler) === null || _b === void 0 ? void 0 : _b.call(this));
208
- if (this.getPortSettings) {
209
- this._ports = this.getPortSettings();
210
- }
211
- if (this.getCertificationSettings) {
212
- this._cert = this.getCertificationSettings();
213
- }
214
- if (this.getRoutingModules) {
215
- this._routingModules = this.getRoutingModules();
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
- yield ((_c = this.createEntries) === null || _c === void 0 ? void 0 : _c.call(this));
218
- console.log(`\n\n\nStarting ${this._params.name}... `);
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.getRootServices) {
235
- this._rootServices = yield this.getRootServices();
253
+ if (this.logSetup) {
254
+ console.log(`\nRoutes mounted.... server using security: ${this._security}`);
236
255
  }
237
- yield ((_e = this.postProcess) === null || _e === void 0 ? void 0 : _e.call(this));
238
- if (!extended) {
239
- yield this.ready();
240
- if (this.params.title) {
241
- console.log(this.params.title);
242
- console.log(`Version: ${this.params.version}`);
243
- }
244
- fsm_dynamo_1.Dynamo_Log.testSuccess(`${this.params.name} started successfully.`);
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
- catch (error) {
248
- this.constructErrors.push(error);
249
- fsm_dynamo_1.Dynamo_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
250
- throw new fsm_dynamo_1.Dynamo_Error({
251
- errorCode: 'NTS-AS0-001',
252
- error: error,
253
- additionalContent: {
254
- constructErrors: this.constructErrors,
255
- systemControls: this.systemControls,
256
- systemReadies: {
257
- app: this.systemControls.app.getReady(),
258
- mongoose: this.systemControls.mongoose.getReady(),
259
- httpServer: this.systemControls.httpServer.getReady(),
260
- httpsServer: this.systemControls.httpsServer.getReady(),
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
- var _a, _b;
269
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
270
- if (this.logFn)
271
- console.log('\nfn:. ready');
272
- let ready = false;
273
- const start = +new Date();
274
- if (this.constructErrors.length) {
275
- fsm_dynamo_1.Dynamo_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
276
- throw new fsm_dynamo_1.Dynamo_Error({
277
- message: `${this._params.name} start failed. ERRORS`,
278
- additionalContent: this.constructErrors.length === 1 ? this.constructErrors[0] : { errors: this.constructErrors },
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
- while (!ready && +new Date() - start < timeout) {
282
- if (this.systemControls.app.init) {
283
- ready = (this.systemControls.mongoose.getReady() &&
284
- this.systemControls.httpServer.getReady() &&
285
- this.systemControls.httpsServer.getReady());
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
- if (timeout < +new Date() - start) {
295
- fsm_dynamo_1.Dynamo_Log.error(`${this._params.name} start failed. TIMEOUT`, this.constructErrors);
296
- throw new fsm_dynamo_1.Dynamo_Error({
297
- message: `${this._params.name} start failed. TIMEOUT`,
298
- additionalContent: {
299
- constructErrors: this.constructErrors,
300
- systemControls: this.systemControls,
301
- systemReadies: {
302
- mongoose: this.systemControls.mongoose.getReady(),
303
- httpServer: this.systemControls.httpServer.getReady(),
304
- httpsServer: this.systemControls.httpsServer.getReady(),
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.constructErrors.length) {
310
- fsm_dynamo_1.Dynamo_Log.error(`${this._params.name} start failed. ERROR`, this.constructErrors);
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 (ready) {
317
- this.systemControls.app.started = true;
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
- else {
323
- this.systemControls.app.started = false;
324
- let msg = `${this._params.name} start failed. UNKNOWN`;
325
- if (this.systemControls.mongoose.init && !this.systemControls.mongoose.started) {
326
- msg += `\nMongoose start failed.`;
327
- }
328
- if (this.systemControls.httpServer.init && !this.systemControls.httpServer.started) {
329
- msg += `\nHTTP Server start failed.`;
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
- if (this.systemControls.httpsServer.init && !this.systemControls.httpsServer.started) {
332
- msg += `\nHTTPS Server start failed.`;
384
+ else {
385
+ fsm_dynamo_1.Dynamo_Log.error(`\nMongoose not found.`);
333
386
  }
334
- fsm_dynamo_1.Dynamo_Log.error(msg, this.constructErrors);
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
- stop(dontLog) {
354
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
355
- if (this.logFn)
356
- console.log('\nfn:. stop');
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
- if (this.systemControls.httpServer.init) {
372
- this.systemControls.httpServer.started = false;
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
- if (this.systemControls.httpsServer.init) {
384
- this.systemControls.httpsServer.started = false;
385
- if (this.httpsServer) {
386
- yield new Promise((resolve) => {
387
- this.httpsServer.close(resolve);
388
- });
389
- }
390
- else {
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
- if (!dontLog) {
396
- fsm_dynamo_1.Dynamo_Log.test(`${this._params.name} stopped successfully.`);
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
406
- if (this.logFn && this.deepLog)
407
- console.log('\nfn:. startDB');
408
- yield new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
409
- this.systemControls.mongoose.init = true;
410
- this.mongoose.connection
411
- .on('error', (error) => {
412
- this.systemControls.mongoose.started = false;
413
- this.constructErrors.push(error);
414
- fsm_dynamo_1.Dynamo_Log.error('\nUnable to connect to MongoDB server, ERROR: ', error);
415
- reject(new fsm_dynamo_1.Dynamo_Error({
416
- errorCode: 'NTS-AS0-100',
417
- message: `Unable to connect to MongoDB server, ERROR: ${error}`,
418
- error: error,
419
- }));
420
- })
421
- .once('open', () => {
422
- this.systemControls.mongoose.started = true;
423
- fsm_dynamo_1.Dynamo_Log.success('\nConnected to MongoDB\n');
424
- resolve();
425
- });
426
- this.mongoose.connect(this._params.dbUri, {
427
- useNewUrlParser: true,
428
- useUnifiedTopology: true
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
438
- if (this.logFn && this.deepLog)
439
- console.log('\nfn:. initExpresses');
440
- if (this._security && this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
441
- if (!this._ports.httpPort) {
442
- let errorMsg = `\nYou have open routes, but httpPort is not set!` +
443
- `\nsecurity: ${this._security}` +
444
- `\nset httpPort in DynamoBEServer - setupRoutingModules() to enable secure routes.`;
445
- errorMsg += '\n\nThe routes setted to use open server:';
446
- this._routingModules.forEach((module) => {
447
- if (module.security != route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
448
- errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using open sever:`;
449
- module.endpoints.forEach((endpoint) => {
450
- if (endpoint.security != route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
451
- errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
452
- }
453
- });
454
- }
455
- });
456
- let error = new Error('Open routes cannot be established!');
457
- let errorStack = error.stack.split('\n');
458
- errorStack.splice(1, 2);
459
- error.stack = errorStack.join('\n');
460
- fsm_dynamo_1.Dynamo_Log.error(errorMsg);
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
- if (this._security && this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
466
- if (!this._cert || !this._ports.httpsPort) {
467
- let errorMsg = `\nYou have secure routes, but the certification paths or httpsPort are not set!` +
468
- `\nsecurity: ${this._security}` +
469
- `\nset...` +
470
- `\n httpsPort and` +
471
- `\n cert: {` +
472
- `\n keyPath: FileSystem.PathLike,` +
473
- `\n certPath: FileSystem.PathLike,` +
474
- `\n }` +
475
- `\nin DynamoBEServer - getRoutingModules() to enable secure routes.`;
476
- errorMsg += '\n\nThe routes setted to use secure server:';
477
- this._routingModules.forEach((module) => {
478
- if (module.security && module.security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
479
- errorMsg += `\n ${module.route} (security: ${module.security}) \n subroutes using secure sever:`;
480
- module.endpoints.forEach((endpoint) => {
481
- if (endpoint.security && endpoint.security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
482
- errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
483
- }
484
- });
485
- }
486
- });
487
- let error = new Error('Secure routes cannot be established!');
488
- let errorStack = error.stack.split('\n');
489
- errorStack.splice(1, 2);
490
- error.stack = errorStack.join('\n');
491
- fsm_dynamo_1.Dynamo_Log.error(errorMsg);
492
- throw error;
493
- }
494
- yield this.initSecureExpress();
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
503
- if (this.logFn)
504
- console.log('\nfn:. initOpenExpress');
505
- this.openExpress = Express();
506
- this.openExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
515
- if (this.logFn)
516
- console.log('\nfn:. initSecureExpress');
517
- this.secureExpress = Express();
518
- this.secureExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
519
- this.secureExpress.use(BodyParser.json({ limit: '50mb' }));
520
- const options = {
521
- key: FileSystem.readFileSync(this._cert.keyPath),
522
- cert: FileSystem.readFileSync(this._cert.certPath),
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
532
- if (this.logFn && this.deepLog)
533
- console.log('\nfn:. startExpresses');
534
- try {
535
- if (this._security && this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
536
- yield new Promise((resolve, reject) => {
537
- this.systemControls.httpsServer.init = true;
538
- this.httpsServer
539
- .listen(this._ports.httpsPort, 'localhost', 0, () => {
540
- this.systemControls.httpsServer.started = true;
541
- fsm_dynamo_1.Dynamo_Log.success(`\nHTTPS (secure) server is listening on port: ${this._ports.httpsPort}`);
542
- resolve();
543
- })
544
- .on('error', (error) => {
545
- this.systemControls.httpsServer.started = false;
546
- this.constructErrors.push(error);
547
- fsm_dynamo_1.Dynamo_Log.error(`\nHTTPS (secure) server ERROR`, error);
548
- reject(new fsm_dynamo_1.Dynamo_Error({
549
- errorCode: 'NTS-AS0-001',
550
- message: `HTTPS (secure) server ERROR`,
551
- error: error,
552
- }));
553
- })
554
- .on('uncaughtException', (ex) => {
555
- fsm_dynamo_1.Dynamo_Log.warn(`\nHTTPS (secure) server uncaughtException`, new fsm_dynamo_1.Dynamo_Error({
556
- errorCode: 'NTS-AS0-002',
557
- message: `HTTPS (secure) server uncaughtException`,
558
- error: ex,
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
- catch (error) {
593
- fsm_dynamo_1.Dynamo_Log.error(`startExpresses failed...`, error);
594
- throw error;
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
603
- if (this.logFn && this.deepLog)
604
- console.log('\nfn:. mountSecureRoutes');
605
- yield fsm_dynamo_1.Dynamo_Array.asyncForEach(this._routingModules, (module) => tslib_1.__awaiter(this, void 0, void 0, function* () {
606
- if (module.security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
607
- if (this.logSetup) {
608
- console.log(`route mount (secure): ${module.route}`);
609
- }
610
- const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
611
- if (1 < existingRoutes.length) {
612
- let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
613
- let errorStack = error.stack.split('\n');
614
- errorStack.splice(1, 4);
615
- error.stack = errorStack.join('\n');
616
- fsm_dynamo_1.Dynamo_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
617
- throw new fsm_dynamo_1.Dynamo_Error({
618
- errorCode: 'NTS-AS0-005',
619
- message: `ROUTE DUPLICATION: ${module.route}`,
620
- error: error,
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
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
633
- if (this.logFn && this.deepLog)
634
- console.log('\nfn:. mountOpenRoutes');
635
- yield fsm_dynamo_1.Dynamo_Array.asyncForEach(this._routingModules, (module) => tslib_1.__awaiter(this, void 0, void 0, function* () {
636
- if (module.security !== route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
637
- if (this.logSetup) {
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
  /**