@futdevpro/nts-dynamo 1.8.5 → 1.9.2
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/.copilot/patterns.json +1 -1
- package/.eslintrc.json +9 -1
- package/lib/_constants/mocks/app-extended-server.mock.js +5 -5
- package/lib/_constants/mocks/app-extended-server.mock.js.map +1 -1
- package/lib/_constants/mocks/app-server.mock.js +4 -4
- package/lib/_constants/mocks/app-server.mock.js.map +1 -1
- package/lib/_constants/mocks/data-model.mock.d.ts +5 -5
- package/lib/_constants/mocks/data-model.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/data-model.mock.js +4 -4
- package/lib/_constants/mocks/data-model.mock.js.map +1 -1
- package/lib/_constants/mocks/endpoint.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/endpoint.mock.js.map +1 -1
- package/lib/_models/control-models/api-call-params.control-model.js +1 -1
- package/lib/_models/control-models/api-call-params.control-model.js.map +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.js +19 -18
- package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-event.control-model.js +7 -7
- package/lib/_models/control-models/socket-event.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-presence.control-model.js +8 -8
- package/lib/_models/control-models/socket-presence.control-model.js.map +1 -1
- package/lib/_models/interfaces/global-service-settings.interface.d.ts +3 -3
- package/lib/_models/interfaces/global-service-settings.interface.d.ts.map +1 -1
- package/lib/_modules/custom-data/custom-data.controller.js +4 -4
- package/lib/_modules/custom-data/custom-data.controller.js.map +1 -1
- package/lib/_modules/custom-data/custom-data.data-service.d.ts +3 -3
- package/lib/_modules/custom-data/custom-data.data-service.d.ts.map +1 -1
- package/lib/_modules/custom-data/custom-data.data-service.js +4 -4
- package/lib/_modules/custom-data/custom-data.data-service.js.map +1 -1
- package/lib/_modules/custom-data/get-custom-data-routing-module.util.js +1 -1
- package/lib/_modules/custom-data/get-custom-data-routing-module.util.js.map +1 -1
- package/lib/_modules/test/get-test-routing-module.util.js +1 -1
- package/lib/_modules/test/get-test-routing-module.util.js.map +1 -1
- package/lib/_modules/test/test.controller.js +6 -6
- package/lib/_modules/test/test.controller.js.map +1 -1
- package/lib/_modules/usage/get-usage-routing-module.util.js +1 -1
- package/lib/_modules/usage/get-usage-routing-module.util.js.map +1 -1
- package/lib/_modules/usage/usage.controller.js +5 -5
- package/lib/_modules/usage/usage.controller.js.map +1 -1
- package/lib/_modules/usage/usage.data-service.d.ts +8 -8
- package/lib/_modules/usage/usage.data-service.d.ts.map +1 -1
- package/lib/_modules/usage/usage.data-service.js +8 -8
- package/lib/_modules/usage/usage.data-service.js.map +1 -1
- package/lib/_services/base/data.service.d.ts +4 -4
- package/lib/_services/base/data.service.d.ts.map +1 -1
- package/lib/_services/base/data.service.js +35 -35
- package/lib/_services/base/data.service.js.map +1 -1
- package/lib/_services/base/db.service.d.ts +6 -6
- package/lib/_services/base/db.service.d.ts.map +1 -1
- package/lib/_services/base/db.service.js +31 -31
- package/lib/_services/base/db.service.js.map +1 -1
- package/lib/_services/core/api.service.js +25 -25
- package/lib/_services/core/api.service.js.map +1 -1
- package/lib/_services/core/auth.service.d.ts +6 -6
- package/lib/_services/core/auth.service.js +2 -2
- package/lib/_services/core/auth.service.js.map +1 -1
- package/lib/_services/core/email.service.js +23 -23
- package/lib/_services/core/email.service.js.map +1 -1
- package/lib/_services/core/global.service.d.ts +3 -3
- package/lib/_services/core/global.service.d.ts.map +1 -1
- package/lib/_services/core/global.service.js +7 -7
- package/lib/_services/core/global.service.js.map +1 -1
- package/lib/_services/route/controller.service.js +1 -1
- package/lib/_services/route/controller.service.js.map +1 -1
- package/lib/_services/route/routing-module.service.d.ts.map +1 -1
- package/lib/_services/route/routing-module.service.js +23 -12
- package/lib/_services/route/routing-module.service.js.map +1 -1
- package/lib/_services/server/app-extended.server.d.ts +2 -2
- package/lib/_services/server/app-extended.server.js +25 -25
- package/lib/_services/server/app-extended.server.js.map +1 -1
- package/lib/_services/server/app-extended.server.spec.js +3 -3
- package/lib/_services/server/app-extended.server.spec.js.map +1 -1
- package/lib/_services/server/app.server.d.ts +4 -4
- package/lib/_services/server/app.server.d.ts.map +1 -1
- package/lib/_services/server/app.server.js +89 -88
- package/lib/_services/server/app.server.js.map +1 -1
- package/lib/_services/server/app.server.spec.js +5 -5
- package/lib/_services/server/app.server.spec.js.map +1 -1
- package/lib/_services/shared.static-service.d.ts +4 -4
- package/lib/_services/shared.static-service.d.ts.map +1 -1
- package/lib/_services/shared.static-service.js +1 -1
- package/lib/_services/shared.static-service.js.map +1 -1
- package/lib/_services/socket/socket-client.service.js +19 -19
- package/lib/_services/socket/socket-client.service.js.map +1 -1
- package/lib/_services/socket/socket-server.service.js +46 -46
- package/lib/_services/socket/socket-server.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +233 -230
- package/src/_constants/mocks/app-extended-server.mock.ts +8 -8
- package/src/_constants/mocks/app-server.mock.ts +6 -6
- package/src/_constants/mocks/data-model.mock.ts +5 -5
- package/src/_constants/mocks/endpoint.mock.ts +50 -47
- package/src/_models/control-models/api-call-params.control-model.ts +2 -2
- package/src/_models/control-models/endpoint-params.control-model.ts +30 -29
- package/src/_models/control-models/socket-event.control-model.ts +8 -8
- package/src/_models/control-models/socket-presence.control-model.ts +14 -14
- package/src/_models/interfaces/global-service-settings.interface.ts +3 -3
- package/src/_modules/custom-data/custom-data.controller.ts +6 -6
- package/src/_modules/custom-data/custom-data.data-service.ts +5 -5
- package/src/_modules/custom-data/get-custom-data-routing-module.util.ts +2 -2
- package/src/_modules/test/get-test-routing-module.util.ts +2 -2
- package/src/_modules/test/test.controller.ts +7 -7
- package/src/_modules/usage/get-usage-routing-module.util.ts +2 -2
- package/src/_modules/usage/usage.controller.ts +7 -7
- package/src/_modules/usage/usage.data-service.ts +28 -28
- package/src/_services/base/data.service.ts +46 -46
- package/src/_services/base/db.service.ts +45 -45
- package/src/_services/core/api.service.ts +32 -32
- package/src/_services/core/auth.service.ts +9 -9
- package/src/_services/core/email.service.ts +29 -29
- package/src/_services/core/global.service.ts +12 -12
- package/src/_services/route/controller.service.ts +2 -2
- package/src/_services/route/routing-module.service.ts +26 -16
- package/src/_services/server/app-extended.server.spec.ts +4 -4
- package/src/_services/server/app-extended.server.ts +26 -26
- package/src/_services/server/app.server.spec.ts +6 -6
- package/src/_services/server/app.server.ts +99 -97
- package/src/_services/shared.static-service.ts +4 -4
- package/src/_services/socket/socket-client.service.ts +21 -21
- package/src/_services/socket/socket-server.service.ts +52 -52
- package/tsconfig.json +7 -7
|
@@ -59,8 +59,8 @@ const app_system_controls_control_model_1 = require("../../_models/control-model
|
|
|
59
59
|
* matchStatisticsModelParams,
|
|
60
60
|
* matchDataModelParams,
|
|
61
61
|
|
|
62
|
-
*
|
|
63
|
-
*
|
|
62
|
+
* DynamoFM_usageSessionModel_params,
|
|
63
|
+
* DynamoFM_customDataModel_params,
|
|
64
64
|
* ]
|
|
65
65
|
* });
|
|
66
66
|
* }
|
|
@@ -172,6 +172,7 @@ const app_system_controls_control_model_1 = require("../../_models/control-model
|
|
|
172
172
|
*
|
|
173
173
|
*/
|
|
174
174
|
class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
175
|
+
// TODO: rename all DynamoNTS_ > DyNTS_ ------------------------------------------------------------------------------------------------------------------------------------
|
|
175
176
|
systemControls = new app_system_controls_control_model_1.DynamoNTS_AppSystemControls();
|
|
176
177
|
get started() {
|
|
177
178
|
return this.systemControls.app.started;
|
|
@@ -225,32 +226,32 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
225
226
|
constructor(extended) {
|
|
226
227
|
super();
|
|
227
228
|
process.on('unhandledRejection', (reason, p_passWhatIsThis) => {
|
|
228
|
-
fsm_dynamo_1.
|
|
229
|
+
fsm_dynamo_1.DynamoFM_Log.highlightedError('Unhandled Rejection at: ', p_passWhatIsThis, '\nRejection reason:', reason);
|
|
229
230
|
try {
|
|
230
|
-
global_service_1.DynamoNTS_GlobalService.globalErrorHandler?.(new fsm_dynamo_1.
|
|
231
|
+
global_service_1.DynamoNTS_GlobalService.globalErrorHandler?.(new fsm_dynamo_1.DynamoFM_Error({
|
|
231
232
|
errorCode: 'NTS-AS0-BASE-UR',
|
|
232
233
|
message: 'Unhandled Rejection!',
|
|
233
234
|
error: new Error(p_passWhatIsThis),
|
|
234
235
|
additionalContent: { reason, p: p_passWhatIsThis },
|
|
235
|
-
level: fsm_dynamo_1.
|
|
236
|
+
level: fsm_dynamo_1.DynamoFM_ErrorLevel.critical,
|
|
236
237
|
}));
|
|
237
238
|
}
|
|
238
239
|
catch (error) {
|
|
239
|
-
fsm_dynamo_1.
|
|
240
|
+
fsm_dynamo_1.DynamoFM_Log.error('getGlobalErrorHandler ERROR:', error);
|
|
240
241
|
}
|
|
241
242
|
});
|
|
242
243
|
this.asyncConstruct(extended).catch((error) => {
|
|
243
|
-
fsm_dynamo_1.
|
|
244
|
+
fsm_dynamo_1.DynamoFM_Log.error(`\nApplication: ${this._params.name} start failed.` +
|
|
244
245
|
`\n`, error);
|
|
245
246
|
});
|
|
246
247
|
}
|
|
247
248
|
async asyncConstruct(extended) {
|
|
248
249
|
if (this.logFn && this.deepLog)
|
|
249
|
-
fsm_dynamo_1.
|
|
250
|
+
fsm_dynamo_1.DynamoFM_Log.log('\nfn:. asyncConstruct');
|
|
250
251
|
try {
|
|
251
252
|
this.systemControls.app.init = true;
|
|
252
253
|
this._params = this.getAppParams();
|
|
253
|
-
fsm_dynamo_1.
|
|
254
|
+
fsm_dynamo_1.DynamoFM_Log.log(`\n\n\n\n\n\n\n\n\n\n` +
|
|
254
255
|
`Starting ${this._params?.name}... `);
|
|
255
256
|
if (!this._params) {
|
|
256
257
|
throw new Error('getAppParams() must return a DynamoNTS_AppParams object!');
|
|
@@ -258,7 +259,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
258
259
|
process.stdout.write(String.fromCharCode(27) + ']0;' +
|
|
259
260
|
this._params?.name +
|
|
260
261
|
String.fromCharCode(7));
|
|
261
|
-
fsm_dynamo_1.
|
|
262
|
+
fsm_dynamo_1.DynamoFM_error_defaults.issuerSystem = this._params.systemName;
|
|
262
263
|
this.overrideDynamoNTSGlobalSettings?.();
|
|
263
264
|
this.logSetup = global_settings_const_1.DynamoNTS_globalSettings.logSetup;
|
|
264
265
|
this.globalService = global_service_1.DynamoNTS_GlobalService.getInstance();
|
|
@@ -286,7 +287,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
286
287
|
await this.mountSecureRoutes();
|
|
287
288
|
}
|
|
288
289
|
if (this.logSetup) {
|
|
289
|
-
fsm_dynamo_1.
|
|
290
|
+
fsm_dynamo_1.DynamoFM_Log.log(`\nRoutes mounted.... server using security: ${this._security}`);
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
293
|
if (this.getRootServices) {
|
|
@@ -296,17 +297,17 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
296
297
|
if (!extended) {
|
|
297
298
|
await this.ready();
|
|
298
299
|
if (this.params.title) {
|
|
299
|
-
fsm_dynamo_1.
|
|
300
|
+
fsm_dynamo_1.DynamoFM_Log.success(this.params.title);
|
|
300
301
|
}
|
|
301
|
-
fsm_dynamo_1.
|
|
302
|
-
/*
|
|
303
|
-
fsm_dynamo_1.
|
|
302
|
+
fsm_dynamo_1.DynamoFM_Log.info(`Version: ${this.params.version}`);
|
|
303
|
+
/* DynamoFM_Log.info(`NTS Version: ${this.ntsVersion}`); */
|
|
304
|
+
fsm_dynamo_1.DynamoFM_Log.H_success(`${this.params.name} started successfully.`);
|
|
304
305
|
}
|
|
305
306
|
}
|
|
306
307
|
catch (error) {
|
|
307
308
|
this.constructErrors.push(error);
|
|
308
|
-
fsm_dynamo_1.
|
|
309
|
-
throw new fsm_dynamo_1.
|
|
309
|
+
fsm_dynamo_1.DynamoFM_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
|
|
310
|
+
throw new fsm_dynamo_1.DynamoFM_Error({
|
|
310
311
|
...this._getDefaultErrorSettings('asyncConstruct', error),
|
|
311
312
|
errorCode: 'NTS-AS0-001',
|
|
312
313
|
additionalContent: {
|
|
@@ -324,12 +325,12 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
324
325
|
}
|
|
325
326
|
async ready(timeout = 4 * fsm_dynamo_1.second) {
|
|
326
327
|
if (this.logFn)
|
|
327
|
-
fsm_dynamo_1.
|
|
328
|
+
fsm_dynamo_1.DynamoFM_Log.log('\nfn:. ready');
|
|
328
329
|
let ready = false;
|
|
329
330
|
const start = +new Date();
|
|
330
331
|
if (this.constructErrors.length) {
|
|
331
|
-
fsm_dynamo_1.
|
|
332
|
-
throw new fsm_dynamo_1.
|
|
332
|
+
fsm_dynamo_1.DynamoFM_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
|
|
333
|
+
throw new fsm_dynamo_1.DynamoFM_Error({
|
|
333
334
|
...this._getDefaultErrorSettings('ready', new Error(`${this._params.name} start failed. ERRORS`)),
|
|
334
335
|
errorCode: 'NTS-AS0-R1',
|
|
335
336
|
additionalContent: this.constructErrors.length === 1 ?
|
|
@@ -344,15 +345,15 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
344
345
|
this.systemControls.httpsServer.getReady());
|
|
345
346
|
}
|
|
346
347
|
else {
|
|
347
|
-
fsm_dynamo_1.
|
|
348
|
+
fsm_dynamo_1.DynamoFM_Log.error(`${this.params.name} APP NOT INITIALIZED while trying to get ready.`);
|
|
348
349
|
}
|
|
349
350
|
if (!ready) {
|
|
350
|
-
await (0, fsm_dynamo_1.
|
|
351
|
+
await (0, fsm_dynamo_1.DynamoFM_wait)(100);
|
|
351
352
|
}
|
|
352
353
|
}
|
|
353
354
|
if (timeout < +new Date() - start) {
|
|
354
|
-
fsm_dynamo_1.
|
|
355
|
-
throw new fsm_dynamo_1.
|
|
355
|
+
fsm_dynamo_1.DynamoFM_Log.error(`${this._params.name} start failed. TIMEOUT`, this.constructErrors);
|
|
356
|
+
throw new fsm_dynamo_1.DynamoFM_Error({
|
|
356
357
|
...this._getDefaultErrorSettings('ready', new Error(`${this._params.name} start failed. TIMEOUT`)),
|
|
357
358
|
errorCode: 'NTS-AS0-R2',
|
|
358
359
|
additionalContent: {
|
|
@@ -367,8 +368,8 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
367
368
|
});
|
|
368
369
|
}
|
|
369
370
|
if (this.constructErrors.length) {
|
|
370
|
-
fsm_dynamo_1.
|
|
371
|
-
throw new fsm_dynamo_1.
|
|
371
|
+
fsm_dynamo_1.DynamoFM_Log.error(`${this._params.name} start failed. ERROR`, this.constructErrors);
|
|
372
|
+
throw new fsm_dynamo_1.DynamoFM_Error({
|
|
372
373
|
...this._getDefaultErrorSettings('ready', new Error(`${this._params.name} start failed. ERROR`)),
|
|
373
374
|
errorCode: 'NTS-AS0-R3',
|
|
374
375
|
additionalContent: this.constructErrors,
|
|
@@ -377,7 +378,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
377
378
|
if (ready) {
|
|
378
379
|
this.systemControls.app.started = true;
|
|
379
380
|
if (this.logFn && this.deepLog)
|
|
380
|
-
fsm_dynamo_1.
|
|
381
|
+
fsm_dynamo_1.DynamoFM_Log.log('\nfn:. ready: return');
|
|
381
382
|
return;
|
|
382
383
|
}
|
|
383
384
|
else {
|
|
@@ -392,8 +393,8 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
392
393
|
if (this.systemControls.httpsServer.init && !this.systemControls.httpsServer.started) {
|
|
393
394
|
msg += `\nHTTPS Server start failed.`;
|
|
394
395
|
}
|
|
395
|
-
fsm_dynamo_1.
|
|
396
|
-
throw new fsm_dynamo_1.
|
|
396
|
+
fsm_dynamo_1.DynamoFM_Log.error(msg, this.constructErrors);
|
|
397
|
+
throw new fsm_dynamo_1.DynamoFM_Error({
|
|
397
398
|
...this._getDefaultErrorSettings('ready', new Error(msg)),
|
|
398
399
|
errorCode: 'NTS-AS0-R4',
|
|
399
400
|
additionalContent: {
|
|
@@ -411,21 +412,21 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
411
412
|
}
|
|
412
413
|
}
|
|
413
414
|
async stop(dontLog) {
|
|
414
|
-
fsm_dynamo_1.
|
|
415
|
+
fsm_dynamo_1.DynamoFM_Log.info('\nstoping server...\n');
|
|
415
416
|
await this.ready();
|
|
416
417
|
if (this.started) {
|
|
417
418
|
if (this.systemControls.mongoose.init) {
|
|
418
|
-
fsm_dynamo_1.
|
|
419
|
+
fsm_dynamo_1.DynamoFM_Log.info(`\nstopping Mongoose....`);
|
|
419
420
|
let tryCount = 0;
|
|
420
421
|
while (!this.systemControls.mongoose.started &&
|
|
421
422
|
!this.constructErrors.length &&
|
|
422
423
|
tryCount++ < 10) {
|
|
423
|
-
fsm_dynamo_1.
|
|
424
|
-
await (0, fsm_dynamo_1.
|
|
424
|
+
fsm_dynamo_1.DynamoFM_Log.warn(`Mongoose not even started yet....`);
|
|
425
|
+
await (0, fsm_dynamo_1.DynamoFM_wait)(fsm_dynamo_1.second);
|
|
425
426
|
}
|
|
426
427
|
this.systemControls.mongoose.started = false;
|
|
427
428
|
if (this.mongoose) {
|
|
428
|
-
await fsm_dynamo_1.
|
|
429
|
+
await fsm_dynamo_1.DynamoFM_Array.asyncForEach(Object.keys(this.mongoose.models), async (modelName) => {
|
|
429
430
|
await this.mongoose.deleteModel(modelName);
|
|
430
431
|
});
|
|
431
432
|
const disconnect = new Promise((resolve) => {
|
|
@@ -438,12 +439,12 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
438
439
|
await disconnect;
|
|
439
440
|
while (this.mongoose.connection.readyState !== 0 &&
|
|
440
441
|
!this.constructErrors.length) {
|
|
441
|
-
fsm_dynamo_1.
|
|
442
|
-
await (0, fsm_dynamo_1.
|
|
442
|
+
fsm_dynamo_1.DynamoFM_Log.warn(`\nMongoose still not disconnected....`);
|
|
443
|
+
await (0, fsm_dynamo_1.DynamoFM_wait)(fsm_dynamo_1.second);
|
|
443
444
|
}
|
|
444
445
|
}
|
|
445
446
|
else {
|
|
446
|
-
fsm_dynamo_1.
|
|
447
|
+
fsm_dynamo_1.DynamoFM_Log.error(`\nMongoose not found.`);
|
|
447
448
|
}
|
|
448
449
|
this.systemControls.mongoose.init = false;
|
|
449
450
|
}
|
|
@@ -455,7 +456,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
455
456
|
});
|
|
456
457
|
}
|
|
457
458
|
else {
|
|
458
|
-
fsm_dynamo_1.
|
|
459
|
+
fsm_dynamo_1.DynamoFM_Log.error(`\nHTTP Server not found.`);
|
|
459
460
|
}
|
|
460
461
|
this.systemControls.httpServer.init = false;
|
|
461
462
|
}
|
|
@@ -467,12 +468,12 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
467
468
|
});
|
|
468
469
|
}
|
|
469
470
|
else {
|
|
470
|
-
fsm_dynamo_1.
|
|
471
|
+
fsm_dynamo_1.DynamoFM_Log.error(`\nHTTPS Server not found.`);
|
|
471
472
|
}
|
|
472
473
|
this.systemControls.httpsServer.init = false;
|
|
473
474
|
}
|
|
474
475
|
if (!dontLog) {
|
|
475
|
-
fsm_dynamo_1.
|
|
476
|
+
fsm_dynamo_1.DynamoFM_Log.H_log(`${this._params.name} stopped successfully.`);
|
|
476
477
|
}
|
|
477
478
|
}
|
|
478
479
|
}
|
|
@@ -481,21 +482,21 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
481
482
|
*/
|
|
482
483
|
async startDB() {
|
|
483
484
|
if (this.logFn && this.deepLog)
|
|
484
|
-
fsm_dynamo_1.
|
|
485
|
+
fsm_dynamo_1.DynamoFM_Log.log('\nfn:. startDB');
|
|
485
486
|
await new Promise((resolve, reject) => {
|
|
486
487
|
this.systemControls.mongoose.init = true;
|
|
487
488
|
this.mongoose.connection
|
|
488
489
|
.once('open', () => {
|
|
489
490
|
this.systemControls.mongoose.started = true;
|
|
490
|
-
fsm_dynamo_1.
|
|
491
|
+
fsm_dynamo_1.DynamoFM_Log.success('\nConnected to MongoDB\n');
|
|
491
492
|
resolve();
|
|
492
493
|
})
|
|
493
494
|
.on('error', (error) => {
|
|
494
495
|
if (!this.systemControls.mongoose.started) {
|
|
495
496
|
this.constructErrors.push(error);
|
|
496
497
|
if (this.debugLog)
|
|
497
|
-
fsm_dynamo_1.
|
|
498
|
-
const d_error = new fsm_dynamo_1.
|
|
498
|
+
fsm_dynamo_1.DynamoFM_Log.error('\nUnable to connect to MongoDB server, ERROR: ', error);
|
|
499
|
+
const d_error = new fsm_dynamo_1.DynamoFM_Error({
|
|
499
500
|
...this._getDefaultErrorSettings('startDB', error),
|
|
500
501
|
errorCode: 'NTS-AS0-SDB1',
|
|
501
502
|
message: `Unable to start connection to MongoDB server, ERROR: ${error}`,
|
|
@@ -505,12 +506,12 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
505
506
|
}
|
|
506
507
|
else {
|
|
507
508
|
if (this.debugLog)
|
|
508
|
-
fsm_dynamo_1.
|
|
509
|
-
const d_error = new fsm_dynamo_1.
|
|
509
|
+
fsm_dynamo_1.DynamoFM_Log.error('\nMongoDB ERROR: ', error);
|
|
510
|
+
const d_error = new fsm_dynamo_1.DynamoFM_Error({
|
|
510
511
|
...this._getDefaultErrorSettings('mongoose.connection.on(error)', error),
|
|
511
512
|
errorCode: 'NTS-AS0-SDB2',
|
|
512
513
|
message: `MongoDB ERROR: ${error}`,
|
|
513
|
-
level: fsm_dynamo_1.
|
|
514
|
+
level: fsm_dynamo_1.DynamoFM_ErrorLevel.critical,
|
|
514
515
|
});
|
|
515
516
|
global_service_1.DynamoNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
516
517
|
}
|
|
@@ -526,7 +527,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
526
527
|
*/
|
|
527
528
|
async initExpresses() {
|
|
528
529
|
if (this.logFn && this.deepLog)
|
|
529
|
-
fsm_dynamo_1.
|
|
530
|
+
fsm_dynamo_1.DynamoFM_Log.log('\nfn:. initExpresses');
|
|
530
531
|
if (this._security && this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
531
532
|
if (!this._portSettings.httpPort) {
|
|
532
533
|
let errorMsg = `\nYou have open routes, but httpPort is not set!` +
|
|
@@ -548,7 +549,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
548
549
|
const errorStack = error.stack.split('\n');
|
|
549
550
|
errorStack.splice(1, 2);
|
|
550
551
|
error.stack = errorStack.join('\n');
|
|
551
|
-
fsm_dynamo_1.
|
|
552
|
+
fsm_dynamo_1.DynamoFM_Log.error(errorMsg);
|
|
552
553
|
throw error;
|
|
553
554
|
}
|
|
554
555
|
await this.initOpenExpress();
|
|
@@ -581,7 +582,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
581
582
|
const errorStack = error.stack.split('\n');
|
|
582
583
|
errorStack.splice(1, 2);
|
|
583
584
|
error.stack = errorStack.join('\n');
|
|
584
|
-
fsm_dynamo_1.
|
|
585
|
+
fsm_dynamo_1.DynamoFM_Log.error(errorMsg);
|
|
585
586
|
throw error;
|
|
586
587
|
}
|
|
587
588
|
await this.initSecureExpress();
|
|
@@ -592,7 +593,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
592
593
|
*/
|
|
593
594
|
async initOpenExpress() {
|
|
594
595
|
if (this.logFn)
|
|
595
|
-
fsm_dynamo_1.
|
|
596
|
+
fsm_dynamo_1.DynamoFM_Log.log('\nfn:. initOpenExpress');
|
|
596
597
|
this.openExpress = Express();
|
|
597
598
|
this.openExpress.use(BodyParser.urlencoded(this._portSettings.httpUrlencoded));
|
|
598
599
|
this.openExpress.use(BodyParser.json(this._portSettings.httpJson));
|
|
@@ -602,7 +603,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
602
603
|
*/
|
|
603
604
|
async initSecureExpress() {
|
|
604
605
|
if (this.logFn)
|
|
605
|
-
fsm_dynamo_1.
|
|
606
|
+
fsm_dynamo_1.DynamoFM_Log.log('\nfn:. initSecureExpress');
|
|
606
607
|
this.secureExpress = Express();
|
|
607
608
|
this.secureExpress.use(BodyParser.urlencoded(this._portSettings.httpsUrlencoded));
|
|
608
609
|
this.secureExpress.use(BodyParser.json(this._portSettings.httpsJson));
|
|
@@ -617,7 +618,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
617
618
|
*/
|
|
618
619
|
async startExpresses() {
|
|
619
620
|
if (this.logFn && this.deepLog)
|
|
620
|
-
fsm_dynamo_1.
|
|
621
|
+
fsm_dynamo_1.DynamoFM_Log.log('\nfn:. startExpresses');
|
|
621
622
|
try {
|
|
622
623
|
if (this._security && this._security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
623
624
|
await new Promise((resolve, reject) => {
|
|
@@ -625,14 +626,14 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
625
626
|
this.httpsServer
|
|
626
627
|
.listen(this._portSettings.httpsPort, 'localhost', 0, () => {
|
|
627
628
|
this.systemControls.httpsServer.started = true;
|
|
628
|
-
fsm_dynamo_1.
|
|
629
|
+
fsm_dynamo_1.DynamoFM_Log.success(`\nHTTPS (secure) server is listening on port: ${this._portSettings.httpsPort}`);
|
|
629
630
|
resolve();
|
|
630
631
|
})
|
|
631
632
|
.on('error', (error) => {
|
|
632
633
|
if (this.debugLog)
|
|
633
|
-
fsm_dynamo_1.
|
|
634
|
+
fsm_dynamo_1.DynamoFM_Log.error(`\nHTTPS (secure) server ERROR`, error);
|
|
634
635
|
if (!this.systemControls.httpsServer.started) {
|
|
635
|
-
const d_error = new fsm_dynamo_1.
|
|
636
|
+
const d_error = new fsm_dynamo_1.DynamoFM_Error({
|
|
636
637
|
...this._getDefaultErrorSettings('startExpresses', error),
|
|
637
638
|
errorCode: 'NTS-AS0-SE1',
|
|
638
639
|
message: `HTTPS (secure) start server ERROR`,
|
|
@@ -642,24 +643,24 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
642
643
|
reject(d_error);
|
|
643
644
|
}
|
|
644
645
|
else {
|
|
645
|
-
const d_error = new fsm_dynamo_1.
|
|
646
|
+
const d_error = new fsm_dynamo_1.DynamoFM_Error({
|
|
646
647
|
...this._getDefaultErrorSettings('httpsServer.on(error)', error),
|
|
647
648
|
errorCode: 'NTS-AS0-SE2',
|
|
648
649
|
message: `HTTPS (secure) server ERROR`,
|
|
649
|
-
level: fsm_dynamo_1.
|
|
650
|
+
level: fsm_dynamo_1.DynamoFM_ErrorLevel.serious,
|
|
650
651
|
});
|
|
651
652
|
global_service_1.DynamoNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
652
653
|
}
|
|
653
654
|
})
|
|
654
655
|
.on('uncaughtException', (exception) => {
|
|
655
|
-
const d_error = new fsm_dynamo_1.
|
|
656
|
+
const d_error = new fsm_dynamo_1.DynamoFM_Error({
|
|
656
657
|
...this._getDefaultErrorSettings('httpsServer.on(uncaughtException)', exception),
|
|
657
658
|
errorCode: 'NTS-AS0-SE3',
|
|
658
659
|
message: `HTTPS (secure) server uncaughtException`,
|
|
659
|
-
level: fsm_dynamo_1.
|
|
660
|
+
level: fsm_dynamo_1.DynamoFM_ErrorLevel.critical,
|
|
660
661
|
});
|
|
661
662
|
if (this.debugLog)
|
|
662
|
-
fsm_dynamo_1.
|
|
663
|
+
fsm_dynamo_1.DynamoFM_Log.warn(`\nHTTPS (secure) server uncaughtException`, d_error);
|
|
663
664
|
global_service_1.DynamoNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
664
665
|
});
|
|
665
666
|
});
|
|
@@ -670,14 +671,14 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
670
671
|
this.httpServer = this.openExpress
|
|
671
672
|
.listen(this._portSettings.httpPort, () => {
|
|
672
673
|
this.systemControls.httpServer.started = true;
|
|
673
|
-
fsm_dynamo_1.
|
|
674
|
+
fsm_dynamo_1.DynamoFM_Log.success(`\nHTTP (open) server is listening on port: ${this._portSettings.httpPort}`);
|
|
674
675
|
resolve();
|
|
675
676
|
})
|
|
676
677
|
.on('error', (error) => {
|
|
677
678
|
if (this.debugLog)
|
|
678
|
-
fsm_dynamo_1.
|
|
679
|
+
fsm_dynamo_1.DynamoFM_Log.error(`\nHTTP (open) server ERROR`, error);
|
|
679
680
|
if (!this.systemControls.httpServer.started) {
|
|
680
|
-
const d_error = new fsm_dynamo_1.
|
|
681
|
+
const d_error = new fsm_dynamo_1.DynamoFM_Error({
|
|
681
682
|
...this._getDefaultErrorSettings('startExpresses', error),
|
|
682
683
|
errorCode: 'NTS-AS0-SE3',
|
|
683
684
|
message: `HTTP (open) start server ERROR`,
|
|
@@ -687,31 +688,31 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
687
688
|
reject(d_error);
|
|
688
689
|
}
|
|
689
690
|
else {
|
|
690
|
-
const d_error = new fsm_dynamo_1.
|
|
691
|
+
const d_error = new fsm_dynamo_1.DynamoFM_Error({
|
|
691
692
|
...this._getDefaultErrorSettings('httpServer.on(error)', error),
|
|
692
693
|
errorCode: 'NTS-AS0-SE4',
|
|
693
694
|
message: `HTTP (open) server ERROR`,
|
|
694
|
-
level: fsm_dynamo_1.
|
|
695
|
+
level: fsm_dynamo_1.DynamoFM_ErrorLevel.serious,
|
|
695
696
|
});
|
|
696
697
|
global_service_1.DynamoNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
697
698
|
}
|
|
698
699
|
})
|
|
699
700
|
.on('uncaughtException', (ex) => {
|
|
700
|
-
const d_error = new fsm_dynamo_1.
|
|
701
|
+
const d_error = new fsm_dynamo_1.DynamoFM_Error({
|
|
701
702
|
...this._getDefaultErrorSettings('httpServer.on(uncaughtException)', ex),
|
|
702
703
|
errorCode: 'NTS-AS0-SE5',
|
|
703
704
|
message: `HTTP (open) server uncaughtException`,
|
|
704
|
-
level: fsm_dynamo_1.
|
|
705
|
+
level: fsm_dynamo_1.DynamoFM_ErrorLevel.critical,
|
|
705
706
|
});
|
|
706
707
|
if (this.debugLog)
|
|
707
|
-
fsm_dynamo_1.
|
|
708
|
+
fsm_dynamo_1.DynamoFM_Log.warn(`\nHTTP (open) server uncaughtException`, d_error);
|
|
708
709
|
global_service_1.DynamoNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
709
710
|
});
|
|
710
711
|
});
|
|
711
712
|
}
|
|
712
713
|
}
|
|
713
714
|
catch (error) {
|
|
714
|
-
fsm_dynamo_1.
|
|
715
|
+
fsm_dynamo_1.DynamoFM_Log.error(`startExpresses failed...`, error);
|
|
715
716
|
throw error;
|
|
716
717
|
}
|
|
717
718
|
}
|
|
@@ -721,7 +722,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
721
722
|
async expressErrorHandling(error, req, res, next) {
|
|
722
723
|
try {
|
|
723
724
|
if (error) {
|
|
724
|
-
const d_error = new fsm_dynamo_1.
|
|
725
|
+
const d_error = new fsm_dynamo_1.DynamoFM_Error({
|
|
725
726
|
...this._getDefaultErrorSettings('expressErrorHandling', error),
|
|
726
727
|
errorCode: 'NTS-AS0-EEH1',
|
|
727
728
|
message: `Express ERROR`,
|
|
@@ -729,17 +730,17 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
729
730
|
req,
|
|
730
731
|
res,
|
|
731
732
|
},
|
|
732
|
-
level: fsm_dynamo_1.
|
|
733
|
+
level: fsm_dynamo_1.DynamoFM_ErrorLevel.error,
|
|
733
734
|
});
|
|
734
735
|
await global_service_1.DynamoNTS_GlobalService.globalErrorHandler?.(d_error, req, res);
|
|
735
736
|
}
|
|
736
737
|
else {
|
|
737
|
-
fsm_dynamo_1.
|
|
738
|
+
fsm_dynamo_1.DynamoFM_Log.H_error('WTF??? express error; without error?...' +
|
|
738
739
|
'\nerr:', error, '\nreq:', req, '\nres:', res);
|
|
739
740
|
}
|
|
740
741
|
}
|
|
741
742
|
catch (error) {
|
|
742
|
-
fsm_dynamo_1.
|
|
743
|
+
fsm_dynamo_1.DynamoFM_Log.H_error('MULTILEVEL ERROR (expressErrorHandling)....' +
|
|
743
744
|
'\n', error);
|
|
744
745
|
}
|
|
745
746
|
}
|
|
@@ -748,12 +749,12 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
748
749
|
*/
|
|
749
750
|
async mountSecureRoutes() {
|
|
750
751
|
if (this.logFn && this.deepLog)
|
|
751
|
-
fsm_dynamo_1.
|
|
752
|
+
fsm_dynamo_1.DynamoFM_Log.log('\nfn:. mountSecureRoutes');
|
|
752
753
|
this.openExpress.use((error, req, res, next) => this.expressErrorHandling(error, req, res, next));
|
|
753
|
-
await fsm_dynamo_1.
|
|
754
|
+
await fsm_dynamo_1.DynamoFM_Array.asyncForEach(this._routingModules, async (module) => {
|
|
754
755
|
if (module.security !== route_security_enum_1.DynamoNTS_RouteSecurity.open) {
|
|
755
756
|
if (this.logSetup) {
|
|
756
|
-
fsm_dynamo_1.
|
|
757
|
+
fsm_dynamo_1.DynamoFM_Log.log(`route mount (secure): ${module.route}`);
|
|
757
758
|
}
|
|
758
759
|
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
759
760
|
if (1 < existingRoutes.length) {
|
|
@@ -761,8 +762,8 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
761
762
|
const errorStack = error.stack.split('\n');
|
|
762
763
|
errorStack.splice(1, 4);
|
|
763
764
|
error.stack = errorStack.join('\n');
|
|
764
|
-
fsm_dynamo_1.
|
|
765
|
-
throw new fsm_dynamo_1.
|
|
765
|
+
fsm_dynamo_1.DynamoFM_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
766
|
+
throw new fsm_dynamo_1.DynamoFM_Error({
|
|
766
767
|
...this._getDefaultErrorSettings('mountSecureRoutes', error),
|
|
767
768
|
errorCode: 'NTS-AS0-MSR1',
|
|
768
769
|
message: `ROUTE DUPLICATION: ${module.route}`,
|
|
@@ -777,12 +778,12 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
777
778
|
*/
|
|
778
779
|
async mountOpenRoutes() {
|
|
779
780
|
if (this.logFn && this.deepLog)
|
|
780
|
-
fsm_dynamo_1.
|
|
781
|
+
fsm_dynamo_1.DynamoFM_Log.log('\nfn:. mountOpenRoutes');
|
|
781
782
|
this.openExpress.use((error, req, res, next) => this.expressErrorHandling(error, req, res, next));
|
|
782
|
-
await fsm_dynamo_1.
|
|
783
|
+
await fsm_dynamo_1.DynamoFM_Array.asyncForEach(this._routingModules, async (module) => {
|
|
783
784
|
if (module.security !== route_security_enum_1.DynamoNTS_RouteSecurity.secure) {
|
|
784
785
|
if (this.logSetup) {
|
|
785
|
-
fsm_dynamo_1.
|
|
786
|
+
fsm_dynamo_1.DynamoFM_Log.log(`route mount (open): ${module.route}`);
|
|
786
787
|
}
|
|
787
788
|
const existingRoutes = this._routingModules.filter((mod) => mod.route === module.route);
|
|
788
789
|
if (1 < existingRoutes.length) {
|
|
@@ -790,8 +791,8 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
790
791
|
const errorStack = error.stack.split('\n');
|
|
791
792
|
errorStack.splice(1, 4);
|
|
792
793
|
error.stack = errorStack.join('\n');
|
|
793
|
-
fsm_dynamo_1.
|
|
794
|
-
throw new fsm_dynamo_1.
|
|
794
|
+
fsm_dynamo_1.DynamoFM_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
795
|
+
throw new fsm_dynamo_1.DynamoFM_Error({
|
|
795
796
|
...this._getDefaultErrorSettings('mountOpenRoutes', error),
|
|
796
797
|
errorCode: 'NTS-AS0-MOR1',
|
|
797
798
|
message: `ROUTE DUPLICATION: ${module.route}`,
|
|
@@ -806,10 +807,10 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
806
807
|
*/
|
|
807
808
|
setSecurity() {
|
|
808
809
|
if (this.logFn && this.deepLog)
|
|
809
|
-
fsm_dynamo_1.
|
|
810
|
+
fsm_dynamo_1.DynamoFM_Log.log('\nfn:. setSecurity');
|
|
810
811
|
this._routingModules.forEach((module) => {
|
|
811
812
|
if (!module.security) {
|
|
812
|
-
fsm_dynamo_1.
|
|
813
|
+
fsm_dynamo_1.DynamoFM_Log.warn(`RoutingModule security is not set for ${module.route}\n`);
|
|
813
814
|
}
|
|
814
815
|
else if (!this._security) {
|
|
815
816
|
this._security = module.security;
|
|
@@ -827,7 +828,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
827
828
|
if (this._routingModules.length === 0) {
|
|
828
829
|
msg += '\n - no RoutingModule found -\n';
|
|
829
830
|
}
|
|
830
|
-
fsm_dynamo_1.
|
|
831
|
+
fsm_dynamo_1.DynamoFM_Log.warn(msg);
|
|
831
832
|
}
|
|
832
833
|
}
|
|
833
834
|
_getDefaultErrorSettings(fnName, error) {
|
|
@@ -838,7 +839,7 @@ class DynamoNTS_App extends singleton_service_1.DynamoNTS_SingletonService {
|
|
|
838
839
|
userMessage: error?.__userMessage ?? this.defaultErrorUserMsg,
|
|
839
840
|
issuerService: `${this?.constructor?.name}-DynamoNTS_App`,
|
|
840
841
|
error: error,
|
|
841
|
-
level: fsm_dynamo_1.
|
|
842
|
+
level: fsm_dynamo_1.DynamoFM_ErrorLevel.fatal,
|
|
842
843
|
};
|
|
843
844
|
}
|
|
844
845
|
}
|