@futdevpro/nts-dynamo 1.9.33 → 1.9.35
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/build/_models/control-models/endpoint-params.control-model.d.ts +2 -1
- package/build/_models/control-models/endpoint-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/endpoint-params.control-model.js +15 -8
- package/build/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/build/_models/control-models/system-control.control-model.d.ts +1 -1
- package/build/_models/control-models/system-control.control-model.d.ts.map +1 -1
- package/build/_models/control-models/system-control.control-model.js +1 -1
- package/build/_models/control-models/system-control.control-model.js.map +1 -1
- package/build/_modules/socket/_services/app-extended.server.d.ts.map +1 -1
- package/build/_modules/socket/_services/app-extended.server.js +32 -30
- package/build/_modules/socket/_services/app-extended.server.js.map +1 -1
- package/build/_modules/socket/_services/app-extended.server.spec.js +51 -14
- package/build/_modules/socket/_services/app-extended.server.spec.js.map +1 -1
- package/build/_modules/usage/usage.controller.d.ts.map +1 -1
- package/build/_modules/usage/usage.controller.js +1 -2
- package/build/_modules/usage/usage.controller.js.map +1 -1
- package/build/_services/core/email.service.d.ts +1 -1
- package/build/_services/core/email.service.d.ts.map +1 -1
- package/build/_services/core/email.service.js +8 -11
- package/build/_services/core/email.service.js.map +1 -1
- package/build/_services/core/global.service.d.ts +14 -4
- package/build/_services/core/global.service.d.ts.map +1 -1
- package/build/_services/core/global.service.js +72 -15
- package/build/_services/core/global.service.js.map +1 -1
- package/build/_services/server/app.server.d.ts +2 -0
- package/build/_services/server/app.server.d.ts.map +1 -1
- package/build/_services/server/app.server.js +63 -59
- package/build/_services/server/app.server.js.map +1 -1
- package/build/_services/server/app.server.spec.js +21 -6
- package/build/_services/server/app.server.spec.js.map +1 -1
- package/package.json +1 -1
- package/src/_models/control-models/endpoint-params.control-model.ts +15 -9
- package/src/_models/control-models/system-control.control-model.ts +1 -1
- package/src/_modules/socket/_services/app-extended.server.spec.ts +59 -20
- package/src/_modules/socket/_services/app-extended.server.ts +48 -42
- package/src/_modules/usage/usage.controller.ts +1 -2
- package/src/_services/core/email.service.ts +14 -16
- package/src/_services/core/global.service.ts +44 -22
- package/src/_services/server/app.server.spec.ts +26 -7
- package/src/_services/server/app.server.ts +103 -144
|
@@ -4,7 +4,9 @@ import { Request, Response } from 'express';
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
DyFM_Metadata, DyFM_DataModel_Params, DyFM_Log, DyFM_Error, DyFM_Array,
|
|
7
|
-
DyFM_errorFlag
|
|
7
|
+
DyFM_errorFlag,
|
|
8
|
+
DyFM_AnyError,
|
|
9
|
+
DyFM_Error_Settings
|
|
8
10
|
} from '@futdevpro/fsm-dynamo';
|
|
9
11
|
import { DyNTS_App_Params } from '../../_models/control-models/app-params.control-model';
|
|
10
12
|
|
|
@@ -49,13 +51,12 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
49
51
|
authService: DyNTS_AuthService;
|
|
50
52
|
dbServiceCollection: DyNTS_Service_Collection<DyNTS_DBService<any>>;
|
|
51
53
|
emailServiceCollection: DyNTS_Service_Collection<DyNTS_EmailService>;
|
|
54
|
+
|
|
55
|
+
static readonly defaultErrorUserMsg: string =
|
|
56
|
+
`We encountered an unhandled Control Service Error, ` +
|
|
57
|
+
`\nplease contact the responsible development team.`;
|
|
52
58
|
|
|
53
|
-
static globalErrorHandler?:
|
|
54
|
-
err: any,
|
|
55
|
-
req?: Request,
|
|
56
|
-
res?: Response,
|
|
57
|
-
issuer?: string
|
|
58
|
-
) => Promise<void>;
|
|
59
|
+
static globalErrorHandler?: DyNTS_GlobalErrorHandlerFn;
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* You need to setup global Services through this function
|
|
@@ -73,8 +74,8 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
73
74
|
await this.setErrorHandler(set?.errorHandler);
|
|
74
75
|
} catch (error) {
|
|
75
76
|
throw new DyFM_Error({
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
...this.getDefaultErrorSettings('setServices', error, 'DyNTS_GlobalService'),
|
|
78
|
+
|
|
78
79
|
errorCode: 'NTS-GS0-SS0',
|
|
79
80
|
});
|
|
80
81
|
}
|
|
@@ -86,8 +87,12 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
86
87
|
dbModels?.forEach((dbModel: DyFM_DataModel_Params): void => {
|
|
87
88
|
if (!dbModel.constructed) {
|
|
88
89
|
throw new DyFM_Error({
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
...this.getDefaultErrorSettings(
|
|
91
|
+
'setDBServices',
|
|
92
|
+
new Error(`dbModel is not constructed!`),
|
|
93
|
+
'DyNTS_GlobalService'
|
|
94
|
+
),
|
|
95
|
+
|
|
91
96
|
errorCode: 'NTS-GS0-SDBS1',
|
|
92
97
|
additionalContent: {
|
|
93
98
|
dbModel: dbModel,
|
|
@@ -101,9 +106,8 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
101
106
|
DyFM_Log.error(`Failed to create DyNTS_DBService (${dbModel.dataName}).`, error);
|
|
102
107
|
|
|
103
108
|
throw new DyFM_Error({
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
error: error,
|
|
109
|
+
...this.getDefaultErrorSettings('setDBServices', error, 'DyNTS_GlobalService'),
|
|
110
|
+
|
|
107
111
|
additionalContent: {
|
|
108
112
|
dbModel: dbModel,
|
|
109
113
|
},
|
|
@@ -112,8 +116,8 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
112
116
|
});
|
|
113
117
|
} catch (error) {
|
|
114
118
|
throw new DyFM_Error({
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
...this.getDefaultErrorSettings('setDBServices', error, 'DyNTS_GlobalService'),
|
|
120
|
+
|
|
117
121
|
errorCode: 'NTS-GS0-SDBS0',
|
|
118
122
|
});
|
|
119
123
|
}
|
|
@@ -128,8 +132,8 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
128
132
|
}
|
|
129
133
|
} catch (error) {
|
|
130
134
|
throw new DyFM_Error({
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
...this.getDefaultErrorSettings('setAuthService', error, 'DyNTS_GlobalService'),
|
|
136
|
+
|
|
133
137
|
errorCode: 'NTS-GS0-SAS0',
|
|
134
138
|
});
|
|
135
139
|
}
|
|
@@ -140,6 +144,7 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
140
144
|
): Promise<void> {
|
|
141
145
|
try {
|
|
142
146
|
this.instance.emailServiceCollection = emailServiceCollection ?? {};
|
|
147
|
+
|
|
143
148
|
await DyFM_Array.asyncForEach(
|
|
144
149
|
Object.keys(this.instance.emailServiceCollection),
|
|
145
150
|
async (key: string): Promise<void> => {
|
|
@@ -150,8 +155,8 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
150
155
|
);
|
|
151
156
|
} catch (error) {
|
|
152
157
|
throw new DyFM_Error({
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
...this.getDefaultErrorSettings('setEmailServices', error, 'DyNTS_GlobalService'),
|
|
159
|
+
|
|
155
160
|
errorCode: 'NTS-GS0-SS4',
|
|
156
161
|
});
|
|
157
162
|
}
|
|
@@ -190,8 +195,8 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
190
195
|
});
|
|
191
196
|
} catch (error) {
|
|
192
197
|
throw new DyFM_Error({
|
|
193
|
-
|
|
194
|
-
|
|
198
|
+
...this.getDefaultErrorSettings('setErrorHandler', error, 'DyNTS_GlobalService'),
|
|
199
|
+
|
|
195
200
|
errorCode: 'NTS-GS0-SEH0',
|
|
196
201
|
});
|
|
197
202
|
}
|
|
@@ -338,4 +343,21 @@ export class DyNTS_GlobalService extends DyNTS_SingletonService {
|
|
|
338
343
|
${names}\n`);
|
|
339
344
|
}
|
|
340
345
|
} */
|
|
346
|
+
|
|
347
|
+
protected static getDefaultErrorSettings(
|
|
348
|
+
fnName: string,
|
|
349
|
+
error: DyFM_AnyError,
|
|
350
|
+
issuer: string
|
|
351
|
+
): DyFM_Error_Settings {
|
|
352
|
+
return {
|
|
353
|
+
status: (error as DyFM_Error)?.___status ?? 500,
|
|
354
|
+
message: (error as Error)?.message ??
|
|
355
|
+
`${fnName} was UNSUCCESSFUL (${DyNTS_global_settings.systemShortCodeName})`,
|
|
356
|
+
addECToUserMsg: !(error as DyFM_Error)?.__userMessage,
|
|
357
|
+
userMessage: (error as DyFM_Error)?.__userMessage ?? this.defaultErrorUserMsg,
|
|
358
|
+
issuer: issuer,
|
|
359
|
+
issuerService: this.constructor?.name,
|
|
360
|
+
error: error,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
341
363
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { DyFM_Log, DyFM_delay } from '@futdevpro/fsm-dynamo';
|
|
2
|
+
import { DyFM_Error, DyFM_Log, DyFM_delay } from '@futdevpro/fsm-dynamo';
|
|
3
3
|
import { DyNTS_AppBase_Mock, DyNTS_AppFull_Mock } from '../../_modules/mock/app-server.mock';
|
|
4
4
|
|
|
5
5
|
describe('DyNTS_App AND DyNTS_AppExtended?;', (): void => {
|
|
@@ -15,15 +15,23 @@ describe('DyNTS_App AND DyNTS_AppExtended?;', (): void => {
|
|
|
15
15
|
await DyFM_delay(100);
|
|
16
16
|
|
|
17
17
|
await app.ready();
|
|
18
|
+
|
|
19
|
+
await DyFM_delay(100);
|
|
18
20
|
} catch (error) {
|
|
19
|
-
DyFM_Log.test('error', error);
|
|
21
|
+
DyFM_Log.test('test beforeEach error:', (error as DyFM_Error)?._message);
|
|
20
22
|
}
|
|
21
23
|
});
|
|
22
24
|
|
|
23
25
|
afterEach(async (): Promise<void> => {
|
|
24
|
-
|
|
26
|
+
try {
|
|
27
|
+
await DyFM_delay(100);
|
|
28
|
+
|
|
29
|
+
await app.stop();
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
app = null;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
DyFM_Log.test('test afterEach error:', (error as DyFM_Error)?._message);
|
|
34
|
+
}
|
|
27
35
|
});
|
|
28
36
|
|
|
29
37
|
it('should be created', (): void => {
|
|
@@ -41,16 +49,27 @@ describe('DyNTS_App AND DyNTS_AppExtended?;', (): void => {
|
|
|
41
49
|
beforeEach(async (): Promise<void> => {
|
|
42
50
|
try {
|
|
43
51
|
app = new DyNTS_AppFull_Mock();
|
|
52
|
+
|
|
53
|
+
await DyFM_delay(100);
|
|
54
|
+
|
|
44
55
|
await app.ready();
|
|
56
|
+
|
|
57
|
+
await DyFM_delay(100);
|
|
45
58
|
} catch (error) {
|
|
46
|
-
DyFM_Log.test('error', error);
|
|
59
|
+
DyFM_Log.test('test beforeEach error:', (error as DyFM_Error)?._message);
|
|
47
60
|
}
|
|
48
61
|
});
|
|
49
62
|
|
|
50
63
|
afterEach(async (): Promise<void> => {
|
|
51
|
-
|
|
64
|
+
try {
|
|
65
|
+
await DyFM_delay(100);
|
|
66
|
+
|
|
67
|
+
await app.stop();
|
|
52
68
|
|
|
53
|
-
|
|
69
|
+
app = null;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
DyFM_Log.test('test afterEach error:', (error as DyFM_Error)?._message);
|
|
72
|
+
}
|
|
54
73
|
});
|
|
55
74
|
|
|
56
75
|
it('should be created', (): void => {
|
|
@@ -250,6 +250,8 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
250
250
|
|
|
251
251
|
private _routingModules: DyNTS_RoutingModule[] = [];
|
|
252
252
|
|
|
253
|
+
protected readonly defaultReadyTimeout: number = 10 * second;
|
|
254
|
+
|
|
253
255
|
override readonly defaultErrorUserMsg =
|
|
254
256
|
`We encountered an unhandled Server Error, ` +
|
|
255
257
|
`\nplease contact the responsible development team.` +
|
|
@@ -310,6 +312,8 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
310
312
|
`Application: "${this.params?.name}" start failed. (constructor asyncConstruct.catch)`
|
|
311
313
|
);
|
|
312
314
|
}
|
|
315
|
+
|
|
316
|
+
DyFM_Log.H_warn('T1000\n', error?.additionalContent);
|
|
313
317
|
});
|
|
314
318
|
}
|
|
315
319
|
|
|
@@ -402,13 +406,21 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
402
406
|
} catch (error) {
|
|
403
407
|
this.constructErrors.push(error);
|
|
404
408
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
409
|
+
if (this.deepLog) {
|
|
410
|
+
if (DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
411
|
+
DyFM_Log.H_error(
|
|
412
|
+
`"${this._params.name}" start failed (in asyncConstruct (highDetailedLog)). `,
|
|
413
|
+
`\n\n construct ERRORS:`, this.constructErrors,
|
|
414
|
+
'\n\nlast error:', error
|
|
415
|
+
);
|
|
416
|
+
} else {
|
|
417
|
+
DyFM_Log.H_error(
|
|
418
|
+
`"${this._params.name}" start failed (in asyncConstruct). `,
|
|
419
|
+
`\n\n construct ERRORS:`, this.getSimplifiedConstructErrors(),
|
|
420
|
+
'\n\nlast error:', error instanceof DyFM_Error ? error.getErrorSimplified() : error
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
412
424
|
|
|
413
425
|
throw new DyFM_Error({
|
|
414
426
|
...this._getDefaultErrorSettings('asyncConstruct', error),
|
|
@@ -418,10 +430,10 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
418
430
|
constructErrors: this.constructErrors,
|
|
419
431
|
systemControls: this.systemControls,
|
|
420
432
|
systemReadies: {
|
|
421
|
-
app: this.systemControls.app.
|
|
422
|
-
mongoose: this.systemControls.mongoose.
|
|
423
|
-
httpServer: this.systemControls.httpServer.
|
|
424
|
-
httpsServer: this.systemControls.httpsServer.
|
|
433
|
+
app: this.systemControls.app.getIsReady(),
|
|
434
|
+
mongoose: this.systemControls.mongoose.getIsReady(),
|
|
435
|
+
httpServer: this.systemControls.httpServer.getIsReady(),
|
|
436
|
+
httpsServer: this.systemControls.httpsServer.getIsReady(),
|
|
425
437
|
},
|
|
426
438
|
},
|
|
427
439
|
});
|
|
@@ -429,7 +441,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
429
441
|
}
|
|
430
442
|
|
|
431
443
|
// eslint-disable-next-line max-lines-per-function
|
|
432
|
-
async ready(timeout: number =
|
|
444
|
+
async ready(timeout: number = this.defaultReadyTimeout): Promise<void> {
|
|
433
445
|
try {
|
|
434
446
|
if (this.fnLogs) DyFM_Log.log('\nfn:. ready');
|
|
435
447
|
|
|
@@ -439,35 +451,30 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
439
451
|
const start: number = +new Date();
|
|
440
452
|
|
|
441
453
|
if (this.constructErrors.length) {
|
|
442
|
-
if (
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
} else {
|
|
455
|
-
return error;
|
|
456
|
-
}
|
|
457
|
-
}),
|
|
458
|
-
);
|
|
454
|
+
if (this.deepLog) {
|
|
455
|
+
if (DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
456
|
+
DyFM_Log.H_error(
|
|
457
|
+
`"${this._params.name}" start failed. (ready; constructErrors check 1)`,
|
|
458
|
+
`\n construct ERRORS:`, this.constructErrors
|
|
459
|
+
);
|
|
460
|
+
} else {
|
|
461
|
+
DyFM_Log.H_error(
|
|
462
|
+
`"${this._params.name}" start failed. (ready; constructErrors check 1)`,
|
|
463
|
+
`\n construct ERRORS:`, this.getSimplifiedConstructErrors(),
|
|
464
|
+
);
|
|
465
|
+
}
|
|
459
466
|
}
|
|
460
467
|
|
|
461
468
|
throw new DyFM_Error({
|
|
462
469
|
...this._getDefaultErrorSettings(
|
|
463
470
|
'ready',
|
|
464
|
-
new Error(
|
|
471
|
+
new Error(`"${this._params.name}" start failed.`)
|
|
465
472
|
),
|
|
466
473
|
|
|
467
474
|
errorCode: 'NTS-AS0-R01',
|
|
468
475
|
additionalContent:
|
|
469
476
|
this.constructErrors.length === 1 ?
|
|
470
|
-
this.constructErrors[0] :
|
|
477
|
+
{ error: this.constructErrors[0] } :
|
|
471
478
|
{ errors: this.constructErrors },
|
|
472
479
|
});
|
|
473
480
|
}
|
|
@@ -475,12 +482,12 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
475
482
|
while (!ready && +new Date() - start < timeout) {
|
|
476
483
|
if (this.systemControls.app.init) {
|
|
477
484
|
ready = (
|
|
478
|
-
this.systemControls.mongoose.
|
|
479
|
-
this.systemControls.httpServer.
|
|
480
|
-
this.systemControls.httpsServer.
|
|
485
|
+
this.systemControls.mongoose.getIsReady() &&
|
|
486
|
+
this.systemControls.httpServer.getIsReady() &&
|
|
487
|
+
this.systemControls.httpsServer.getIsReady()
|
|
481
488
|
);
|
|
482
489
|
} else {
|
|
483
|
-
DyFM_Log.error(
|
|
490
|
+
DyFM_Log.error(`"${this._params.name}" APP NOT INITIALIZED while trying to get ready.`);
|
|
484
491
|
}
|
|
485
492
|
|
|
486
493
|
if (!ready) {
|
|
@@ -489,29 +496,24 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
489
496
|
}
|
|
490
497
|
|
|
491
498
|
if (timeout < +new Date() - start) {
|
|
492
|
-
if (
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
} else {
|
|
505
|
-
return error;
|
|
506
|
-
}
|
|
507
|
-
}),
|
|
508
|
-
);
|
|
499
|
+
if (this.deepLog) {
|
|
500
|
+
if (DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
501
|
+
DyFM_Log.H_error(
|
|
502
|
+
`"${this._params.name}" start failed. (ready; TIMEOUT check)`,
|
|
503
|
+
`\n construct ERRORS:`, this.constructErrors
|
|
504
|
+
);
|
|
505
|
+
} else {
|
|
506
|
+
DyFM_Log.H_error(
|
|
507
|
+
`"${this._params.name}" start failed. (ready; TIMEOUT check)`,
|
|
508
|
+
`\n construct ERRORS:`, this.getSimplifiedConstructErrors(),
|
|
509
|
+
);
|
|
510
|
+
}
|
|
509
511
|
}
|
|
510
512
|
|
|
511
513
|
throw new DyFM_Error({
|
|
512
514
|
...this._getDefaultErrorSettings(
|
|
513
515
|
'ready',
|
|
514
|
-
new Error(
|
|
516
|
+
new Error(`"${this._params.name}" start failed. TIMEOUT`)
|
|
515
517
|
),
|
|
516
518
|
|
|
517
519
|
errorCode: 'NTS-AS0-R02',
|
|
@@ -519,38 +521,33 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
519
521
|
constructErrors: this.constructErrors,
|
|
520
522
|
systemControls: this.systemControls,
|
|
521
523
|
systemReadies: {
|
|
522
|
-
mongoose: this.systemControls.mongoose.
|
|
523
|
-
httpServer: this.systemControls.httpServer.
|
|
524
|
-
httpsServer: this.systemControls.httpsServer.
|
|
524
|
+
mongoose: this.systemControls.mongoose.getIsReady(),
|
|
525
|
+
httpServer: this.systemControls.httpServer.getIsReady(),
|
|
526
|
+
httpsServer: this.systemControls.httpsServer.getIsReady(),
|
|
525
527
|
},
|
|
526
528
|
},
|
|
527
529
|
});
|
|
528
530
|
}
|
|
529
531
|
|
|
530
532
|
if (this.constructErrors.length) {
|
|
531
|
-
if (
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
} else {
|
|
544
|
-
return error;
|
|
545
|
-
}
|
|
546
|
-
}),
|
|
547
|
-
);
|
|
533
|
+
if (this.deepLog) {
|
|
534
|
+
if (DyNTS_global_settings.log_settings.highDetailedLogs) {
|
|
535
|
+
DyFM_Log.H_error(
|
|
536
|
+
`"${this._params.name}" start failed. (ready; constructErrors check 2)`,
|
|
537
|
+
`\n construct ERRORS:`, this.constructErrors
|
|
538
|
+
);
|
|
539
|
+
} else {
|
|
540
|
+
DyFM_Log.H_error(
|
|
541
|
+
`"${this._params.name}" start failed. (ready; constructErrors check 2)`,
|
|
542
|
+
`\n construct ERRORS:`, this.getSimplifiedConstructErrors(),
|
|
543
|
+
);
|
|
544
|
+
}
|
|
548
545
|
}
|
|
549
546
|
|
|
550
547
|
throw new DyFM_Error({
|
|
551
548
|
...this._getDefaultErrorSettings(
|
|
552
549
|
'ready',
|
|
553
|
-
new Error(
|
|
550
|
+
new Error(`"${this._params.name}" start failed.`)
|
|
554
551
|
),
|
|
555
552
|
|
|
556
553
|
errorCode: 'NTS-AS0-R03',
|
|
@@ -568,7 +565,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
568
565
|
|
|
569
566
|
this.systemControls.app.started = false;
|
|
570
567
|
|
|
571
|
-
let msg: string =
|
|
568
|
+
let msg: string = `"${this._params.name}" start failed. UNKNOWN`;
|
|
572
569
|
|
|
573
570
|
if (this.systemControls.mongoose.init && !this.systemControls.mongoose.started) {
|
|
574
571
|
msg += `\nMongoose start failed.`;
|
|
@@ -585,20 +582,17 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
585
582
|
DyFM_Log.error(msg, this.constructErrors);
|
|
586
583
|
|
|
587
584
|
throw new DyFM_Error({
|
|
588
|
-
...this._getDefaultErrorSettings(
|
|
589
|
-
'ready',
|
|
590
|
-
new Error(msg)
|
|
591
|
-
),
|
|
585
|
+
...this._getDefaultErrorSettings('ready', new Error(msg)),
|
|
592
586
|
|
|
593
587
|
errorCode: 'NTS-AS0-R04',
|
|
594
588
|
additionalContent: {
|
|
595
589
|
constructErrors: this.constructErrors,
|
|
596
590
|
systemControls: this.systemControls,
|
|
597
591
|
systemReadies: {
|
|
598
|
-
app: this.systemControls.app.
|
|
599
|
-
mongoose: this.systemControls.mongoose.
|
|
600
|
-
httpServer: this.systemControls.httpServer.
|
|
601
|
-
httpsServer: this.systemControls.httpsServer.
|
|
592
|
+
app: this.systemControls.app.getIsReady(),
|
|
593
|
+
mongoose: this.systemControls.mongoose.getIsReady(),
|
|
594
|
+
httpServer: this.systemControls.httpServer.getIsReady(),
|
|
595
|
+
httpsServer: this.systemControls.httpsServer.getIsReady(),
|
|
602
596
|
},
|
|
603
597
|
},
|
|
604
598
|
error: this.constructErrors?.[0] ?? new Error(),
|
|
@@ -612,6 +606,16 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
612
606
|
}
|
|
613
607
|
}
|
|
614
608
|
|
|
609
|
+
protected getSimplifiedConstructErrors(): string[] {
|
|
610
|
+
return this.constructErrors.map((error: any): any => {
|
|
611
|
+
if (error instanceof DyFM_Error) {
|
|
612
|
+
return error.getErrorSimplified();
|
|
613
|
+
} else {
|
|
614
|
+
return error;
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
|
|
615
619
|
async stop(dontLog?: boolean): Promise<void> {
|
|
616
620
|
try {
|
|
617
621
|
DyFM_Log.info('\nstopping server...\n');
|
|
@@ -695,7 +699,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
695
699
|
await DyFM_wait(second);
|
|
696
700
|
|
|
697
701
|
if (!dontLog) {
|
|
698
|
-
DyFM_Log.H_log(
|
|
702
|
+
DyFM_Log.H_log(`"${this._params.name}" stopped successfully.`);
|
|
699
703
|
}
|
|
700
704
|
}
|
|
701
705
|
} catch (error) {
|
|
@@ -735,10 +739,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
735
739
|
);
|
|
736
740
|
|
|
737
741
|
const d_error: DyFM_Error = new DyFM_Error({
|
|
738
|
-
...this._getDefaultErrorSettings(
|
|
739
|
-
'startDB',
|
|
740
|
-
error
|
|
741
|
-
),
|
|
742
|
+
...this._getDefaultErrorSettings('startDB', error),
|
|
742
743
|
|
|
743
744
|
errorCode: 'NTS-AS0-SDB1',
|
|
744
745
|
message: `Unable to start connection to MongoDB server, ERROR: ${error}`,
|
|
@@ -752,10 +753,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
752
753
|
if (this.debugLog) DyFM_Log.error('\nMongoDB ERROR: ', error);
|
|
753
754
|
|
|
754
755
|
const d_error: DyFM_Error = new DyFM_Error({
|
|
755
|
-
...this._getDefaultErrorSettings(
|
|
756
|
-
'mongoose.connection.on(error)',
|
|
757
|
-
error
|
|
758
|
-
),
|
|
756
|
+
...this._getDefaultErrorSettings('mongoose.connection.on(error)', error),
|
|
759
757
|
|
|
760
758
|
errorCode: 'NTS-AS0-SDB2',
|
|
761
759
|
message: `MongoDB ERROR: ${error}`,
|
|
@@ -875,10 +873,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
875
873
|
}
|
|
876
874
|
} catch (error) {
|
|
877
875
|
throw new DyFM_Error({
|
|
878
|
-
...this._getDefaultErrorSettings(
|
|
879
|
-
'initExpresses',
|
|
880
|
-
error
|
|
881
|
-
),
|
|
876
|
+
...this._getDefaultErrorSettings('initExpresses', error),
|
|
882
877
|
|
|
883
878
|
errorCode: 'NTS-AS0-IE0',
|
|
884
879
|
});
|
|
@@ -936,10 +931,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
936
931
|
|
|
937
932
|
if (!this.systemControls.httpsServer.started) {
|
|
938
933
|
const d_error: DyFM_Error = new DyFM_Error({
|
|
939
|
-
...this._getDefaultErrorSettings(
|
|
940
|
-
'startExpresses',
|
|
941
|
-
error
|
|
942
|
-
),
|
|
934
|
+
...this._getDefaultErrorSettings('startExpresses', error),
|
|
943
935
|
|
|
944
936
|
errorCode: 'NTS-AS0-SE1',
|
|
945
937
|
message: `HTTPS (secure) start server ERROR`,
|
|
@@ -952,10 +944,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
952
944
|
|
|
953
945
|
} else {
|
|
954
946
|
const d_error: DyFM_Error = new DyFM_Error({
|
|
955
|
-
...this._getDefaultErrorSettings(
|
|
956
|
-
'httpsServer.on(error)',
|
|
957
|
-
error
|
|
958
|
-
),
|
|
947
|
+
...this._getDefaultErrorSettings('httpsServer.on(error)', error),
|
|
959
948
|
|
|
960
949
|
errorCode: 'NTS-AS0-SE2',
|
|
961
950
|
message: `HTTPS (secure) server ERROR`,
|
|
@@ -967,10 +956,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
967
956
|
})
|
|
968
957
|
.on('uncaughtException', (exception): void => {
|
|
969
958
|
const d_error: DyFM_Error = new DyFM_Error({
|
|
970
|
-
...this._getDefaultErrorSettings(
|
|
971
|
-
'httpsServer.on(uncaughtException)',
|
|
972
|
-
exception
|
|
973
|
-
),
|
|
959
|
+
...this._getDefaultErrorSettings('httpsServer.on(uncaughtException)', exception),
|
|
974
960
|
|
|
975
961
|
errorCode: 'NTS-AS0-SE3',
|
|
976
962
|
message: `HTTPS (secure) server uncaughtException`,
|
|
@@ -1004,10 +990,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
1004
990
|
|
|
1005
991
|
if (!this.systemControls.httpServer.started) {
|
|
1006
992
|
const d_error: DyFM_Error = new DyFM_Error({
|
|
1007
|
-
...this._getDefaultErrorSettings(
|
|
1008
|
-
'startExpresses',
|
|
1009
|
-
error
|
|
1010
|
-
),
|
|
993
|
+
...this._getDefaultErrorSettings('startExpresses', error),
|
|
1011
994
|
|
|
1012
995
|
errorCode: 'NTS-AS0-SE3',
|
|
1013
996
|
message: `HTTP (open) start server ERROR`,
|
|
@@ -1020,10 +1003,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
1020
1003
|
|
|
1021
1004
|
} else {
|
|
1022
1005
|
const d_error: DyFM_Error = new DyFM_Error({
|
|
1023
|
-
...this._getDefaultErrorSettings(
|
|
1024
|
-
'httpServer.on(error)',
|
|
1025
|
-
error
|
|
1026
|
-
),
|
|
1006
|
+
...this._getDefaultErrorSettings('httpServer.on(error)', error),
|
|
1027
1007
|
|
|
1028
1008
|
errorCode: 'NTS-AS0-SE4',
|
|
1029
1009
|
message: `HTTP (open) server ERROR`,
|
|
@@ -1035,10 +1015,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
1035
1015
|
})
|
|
1036
1016
|
.on('uncaughtException', (exception): void => {
|
|
1037
1017
|
const d_error: DyFM_Error = new DyFM_Error({
|
|
1038
|
-
...this._getDefaultErrorSettings(
|
|
1039
|
-
'httpServer.on(uncaughtException)',
|
|
1040
|
-
exception
|
|
1041
|
-
),
|
|
1018
|
+
...this._getDefaultErrorSettings('httpServer.on(uncaughtException)', exception),
|
|
1042
1019
|
|
|
1043
1020
|
errorCode: 'NTS-AS0-SE5',
|
|
1044
1021
|
message: `HTTP (open) server uncaughtException`,
|
|
@@ -1055,10 +1032,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
1055
1032
|
}
|
|
1056
1033
|
} catch (error) {
|
|
1057
1034
|
throw new DyFM_Error({
|
|
1058
|
-
...this._getDefaultErrorSettings(
|
|
1059
|
-
'startExpresses',
|
|
1060
|
-
error
|
|
1061
|
-
),
|
|
1035
|
+
...this._getDefaultErrorSettings('startExpresses', error),
|
|
1062
1036
|
|
|
1063
1037
|
errorCode: 'NTS-AS0-SE0',
|
|
1064
1038
|
});
|
|
@@ -1072,10 +1046,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
1072
1046
|
try {
|
|
1073
1047
|
if (error) {
|
|
1074
1048
|
const d_error: DyFM_Error = new DyFM_Error({
|
|
1075
|
-
...this._getDefaultErrorSettings(
|
|
1076
|
-
'expressErrorHandling',
|
|
1077
|
-
error
|
|
1078
|
-
),
|
|
1049
|
+
...this._getDefaultErrorSettings('expressErrorHandling', error),
|
|
1079
1050
|
|
|
1080
1051
|
errorCode: 'NTS-AS0-EEH1',
|
|
1081
1052
|
message: `Express ERROR`,
|
|
@@ -1137,10 +1108,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
1137
1108
|
DyFM_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
1138
1109
|
|
|
1139
1110
|
throw new DyFM_Error({
|
|
1140
|
-
...this._getDefaultErrorSettings(
|
|
1141
|
-
'mountSecureRoutes',
|
|
1142
|
-
error
|
|
1143
|
-
),
|
|
1111
|
+
...this._getDefaultErrorSettings('mountSecureRoutes', error),
|
|
1144
1112
|
|
|
1145
1113
|
errorCode: 'NTS-AS0-MSR1',
|
|
1146
1114
|
message: `ROUTE DUPLICATION: ${module.route}`,
|
|
@@ -1153,10 +1121,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
1153
1121
|
);
|
|
1154
1122
|
} catch (error) {
|
|
1155
1123
|
throw new DyFM_Error({
|
|
1156
|
-
...this._getDefaultErrorSettings(
|
|
1157
|
-
'mountSecureRoutes',
|
|
1158
|
-
error
|
|
1159
|
-
),
|
|
1124
|
+
...this._getDefaultErrorSettings('mountSecureRoutes', error),
|
|
1160
1125
|
|
|
1161
1126
|
errorCode: 'NTS-AS0-MSR0',
|
|
1162
1127
|
});
|
|
@@ -1196,10 +1161,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
1196
1161
|
DyFM_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
1197
1162
|
|
|
1198
1163
|
throw new DyFM_Error({
|
|
1199
|
-
...this._getDefaultErrorSettings(
|
|
1200
|
-
'mountOpenRoutes',
|
|
1201
|
-
error
|
|
1202
|
-
),
|
|
1164
|
+
...this._getDefaultErrorSettings('mountOpenRoutes', error),
|
|
1203
1165
|
|
|
1204
1166
|
errorCode: 'NTS-AS0-MOR1',
|
|
1205
1167
|
message: `ROUTE DUPLICATION: ${module.route}`,
|
|
@@ -1212,10 +1174,7 @@ export abstract class DyNTS_App extends DyNTS_SingletonService {
|
|
|
1212
1174
|
);
|
|
1213
1175
|
} catch (error) {
|
|
1214
1176
|
throw new DyFM_Error({
|
|
1215
|
-
...this._getDefaultErrorSettings(
|
|
1216
|
-
'mountOpenRoutes',
|
|
1217
|
-
error
|
|
1218
|
-
),
|
|
1177
|
+
...this._getDefaultErrorSettings('mountOpenRoutes', error),
|
|
1219
1178
|
|
|
1220
1179
|
errorCode: 'NTS-AS0-MOR0',
|
|
1221
1180
|
});
|