@futdevpro/nts-dynamo 1.8.5 → 1.9.1
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/_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.js +17 -17
- 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.js +8 -8
- 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/_models/control-models/api-call-params.control-model.ts +2 -2
- package/src/_models/control-models/endpoint-params.control-model.ts +28 -28
- 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 +9 -9
- 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
|
@@ -5,7 +5,7 @@ import * as NodeMailer from 'nodemailer';
|
|
|
5
5
|
|
|
6
6
|
import { Options as MailOptions, Attachment } from 'nodemailer/lib/mailer';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { DynamoFM_AnyError, DynamoFM_Array, DynamoFM_Error, DynamoFM_Error_Settings, DynamoFM_Log } from '@futdevpro/fsm-dynamo';
|
|
9
9
|
|
|
10
10
|
export interface DynamoNTS_EmailService_Settings {
|
|
11
11
|
host: string,
|
|
@@ -98,7 +98,7 @@ export class DynamoNTS_EmailService {
|
|
|
98
98
|
async asyncPostConstruct(): Promise<void> {
|
|
99
99
|
try {
|
|
100
100
|
if (this.components) {
|
|
101
|
-
await
|
|
101
|
+
await DynamoFM_Array.asyncForEach(
|
|
102
102
|
this.components,
|
|
103
103
|
async (component: DynamoNTS_EmailTemplateComponent): Promise<void> => {
|
|
104
104
|
await this.loadComponent(component);
|
|
@@ -108,9 +108,9 @@ export class DynamoNTS_EmailService {
|
|
|
108
108
|
this.connectComponents();
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
DynamoFM_Log.success(`\nEmailService construction (${this.senderName}) Finished!`);
|
|
112
112
|
} catch (error) {
|
|
113
|
-
throw new
|
|
113
|
+
throw new DynamoFM_Error({
|
|
114
114
|
...this._getDefaultErrorSettings('asyncPostConstruct', error, 'SYSTEM'),
|
|
115
115
|
|
|
116
116
|
errorCode: 'NTS-ES0-APC0',
|
|
@@ -137,7 +137,7 @@ export class DynamoNTS_EmailService {
|
|
|
137
137
|
|
|
138
138
|
} else {
|
|
139
139
|
if (!set.templateComponentName) {
|
|
140
|
-
throw new
|
|
140
|
+
throw new DynamoFM_Error({
|
|
141
141
|
...this._getDefaultErrorSettings(
|
|
142
142
|
'sendEmail',
|
|
143
143
|
new Error(
|
|
@@ -151,7 +151,7 @@ export class DynamoNTS_EmailService {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
if (!this.componentsByName[set.templateComponentName]) {
|
|
154
|
-
throw new
|
|
154
|
+
throw new DynamoFM_Error({
|
|
155
155
|
...this._getDefaultErrorSettings(
|
|
156
156
|
'sendEmail',
|
|
157
157
|
new Error(
|
|
@@ -193,7 +193,7 @@ export class DynamoNTS_EmailService {
|
|
|
193
193
|
});
|
|
194
194
|
} catch (error) {
|
|
195
195
|
if ((error as Error).message?.includes?.('all recipients were rejected')) {
|
|
196
|
-
throw new
|
|
196
|
+
throw new DynamoFM_Error({
|
|
197
197
|
...this._getDefaultErrorSettings('sendEmail', error, issuer),
|
|
198
198
|
|
|
199
199
|
addECToUserMsg: false,
|
|
@@ -203,7 +203,7 @@ export class DynamoNTS_EmailService {
|
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
} else {
|
|
206
|
-
throw new
|
|
206
|
+
throw new DynamoFM_Error({
|
|
207
207
|
...this._getDefaultErrorSettings('sendEmail', error, issuer),
|
|
208
208
|
|
|
209
209
|
errorCode: 'NTS-ES0-SE0',
|
|
@@ -220,7 +220,7 @@ export class DynamoNTS_EmailService {
|
|
|
220
220
|
): string {
|
|
221
221
|
try {
|
|
222
222
|
if (!this.componentsByName[componentName]) {
|
|
223
|
-
throw new
|
|
223
|
+
throw new DynamoFM_Error({
|
|
224
224
|
...this._getDefaultErrorSettings(
|
|
225
225
|
'setupComponent',
|
|
226
226
|
new Error(`No email component found with this name! (${componentName})`),
|
|
@@ -257,7 +257,7 @@ export class DynamoNTS_EmailService {
|
|
|
257
257
|
|
|
258
258
|
return template;
|
|
259
259
|
} catch (error) {
|
|
260
|
-
throw new
|
|
260
|
+
throw new DynamoFM_Error({
|
|
261
261
|
...this._getDefaultErrorSettings('setupComponent', error, issuer),
|
|
262
262
|
|
|
263
263
|
errorCode: 'NTS-ES0-SC0',
|
|
@@ -295,7 +295,7 @@ export class DynamoNTS_EmailService {
|
|
|
295
295
|
const styleSize = this.getStringKBSize(styles);
|
|
296
296
|
|
|
297
297
|
if (this.styleLimitWarning < styleSize) {
|
|
298
|
-
|
|
298
|
+
DynamoFM_Log.warn(
|
|
299
299
|
`\nDynamoNTS EmailService WARNING (${this.serviceName}), ` +
|
|
300
300
|
`\nEmail template styles are too big! (${styleSize}KB)` +
|
|
301
301
|
`\ncomponent: ${component.name} (${component.selector})` +
|
|
@@ -362,7 +362,7 @@ export class DynamoNTS_EmailService {
|
|
|
362
362
|
): string {
|
|
363
363
|
component.properties.forEach((propertyKey: string): void => {
|
|
364
364
|
if (!componentProperties[propertyKey]) {
|
|
365
|
-
throw new
|
|
365
|
+
throw new DynamoFM_Error({
|
|
366
366
|
...this._getDefaultErrorSettings(
|
|
367
367
|
'setupComponent',
|
|
368
368
|
new Error(
|
|
@@ -396,7 +396,7 @@ export class DynamoNTS_EmailService {
|
|
|
396
396
|
this.componentsBySelector[subComponentSelector];
|
|
397
397
|
|
|
398
398
|
if (!subComponent) {
|
|
399
|
-
throw new
|
|
399
|
+
throw new DynamoFM_Error({
|
|
400
400
|
...this._getDefaultErrorSettings(
|
|
401
401
|
'setupComponent',
|
|
402
402
|
new Error(`SubComponent missing from components! (${subComponentSelector})`),
|
|
@@ -454,7 +454,7 @@ export class DynamoNTS_EmailService {
|
|
|
454
454
|
private async loadComponent(component: DynamoNTS_EmailTemplateComponent): Promise<void> {
|
|
455
455
|
try {
|
|
456
456
|
if (this.componentsBySelector[component.selector]) {
|
|
457
|
-
throw new
|
|
457
|
+
throw new DynamoFM_Error({
|
|
458
458
|
...this._getDefaultErrorSettings('loadComponent', new Error(), 'SYSTEM'),
|
|
459
459
|
|
|
460
460
|
errorCode: 'NTS-ES0-LC1',
|
|
@@ -463,7 +463,7 @@ export class DynamoNTS_EmailService {
|
|
|
463
463
|
}
|
|
464
464
|
|
|
465
465
|
if (!component.templatePath && !component.template) {
|
|
466
|
-
throw new
|
|
466
|
+
throw new DynamoFM_Error({
|
|
467
467
|
...this._getDefaultErrorSettings('loadComponent', new Error(), 'SYSTEM'),
|
|
468
468
|
|
|
469
469
|
errorCode: 'NTS-ES0-LC2',
|
|
@@ -483,7 +483,7 @@ export class DynamoNTS_EmailService {
|
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
reject(
|
|
486
|
-
new
|
|
486
|
+
new DynamoFM_Error({
|
|
487
487
|
...this._getDefaultErrorSettings('loadTemplate', err, 'SYSTEM'),
|
|
488
488
|
|
|
489
489
|
errorCode: 'NTS-ES0-LC3',
|
|
@@ -512,7 +512,7 @@ export class DynamoNTS_EmailService {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
reject(
|
|
515
|
-
new
|
|
515
|
+
new DynamoFM_Error({
|
|
516
516
|
...this._getDefaultErrorSettings('loadTemplate', err, 'SYSTEM'),
|
|
517
517
|
|
|
518
518
|
errorCode: 'NTS-ES0-LC4',
|
|
@@ -535,7 +535,7 @@ export class DynamoNTS_EmailService {
|
|
|
535
535
|
|
|
536
536
|
component.properties.forEach((propertyKey: string): void => {
|
|
537
537
|
if (!component.template.includes(`{{${propertyKey}}}`)) {
|
|
538
|
-
throw new
|
|
538
|
+
throw new DynamoFM_Error({
|
|
539
539
|
...this._getDefaultErrorSettings(
|
|
540
540
|
'loadComponent',
|
|
541
541
|
new Error(
|
|
@@ -550,7 +550,7 @@ export class DynamoNTS_EmailService {
|
|
|
550
550
|
}
|
|
551
551
|
});
|
|
552
552
|
} catch (error) {
|
|
553
|
-
throw new
|
|
553
|
+
throw new DynamoFM_Error({
|
|
554
554
|
...this._getDefaultErrorSettings('loadComponent', error, 'SYSTEM'),
|
|
555
555
|
|
|
556
556
|
errorCode: 'NTS-ES0-LC0',
|
|
@@ -577,7 +577,7 @@ export class DynamoNTS_EmailService {
|
|
|
577
577
|
|
|
578
578
|
if (fullSelector) {
|
|
579
579
|
if (!this.componentsBySelector[subComponentSelector]) {
|
|
580
|
-
throw new
|
|
580
|
+
throw new DynamoFM_Error({
|
|
581
581
|
...this._getDefaultErrorSettings(
|
|
582
582
|
'connectComponents',
|
|
583
583
|
new Error(`SubComponent missing from components! (${fullSelector})`),
|
|
@@ -600,7 +600,7 @@ export class DynamoNTS_EmailService {
|
|
|
600
600
|
);
|
|
601
601
|
}
|
|
602
602
|
} catch (error) {
|
|
603
|
-
throw new
|
|
603
|
+
throw new DynamoFM_Error({
|
|
604
604
|
...this._getDefaultErrorSettings('connectComponents', error, 'SYSTEM'),
|
|
605
605
|
|
|
606
606
|
errorCode: 'NTS-ES0-CC0',
|
|
@@ -622,13 +622,13 @@ export class DynamoNTS_EmailService {
|
|
|
622
622
|
|
|
623
623
|
while (propertyOpenTagIndex >= 0) {
|
|
624
624
|
if (propertyCloseTagIndex === -1) {
|
|
625
|
-
|
|
625
|
+
DynamoFM_Log.error(
|
|
626
626
|
`\nDynamoBEEmailService ERROR, missing closing tag from email template! ` +
|
|
627
627
|
`(${propertyOpenTagIndex} -)`,
|
|
628
628
|
propertyKeys
|
|
629
629
|
);
|
|
630
630
|
|
|
631
|
-
throw new
|
|
631
|
+
throw new DynamoFM_Error({
|
|
632
632
|
errorCode: 'NTS-ES0-200',
|
|
633
633
|
addECToUserMsg: true,
|
|
634
634
|
message: `ERROR, missing closing tag from email template! (${propertyOpenTagIndex} -)`,
|
|
@@ -650,7 +650,7 @@ export class DynamoNTS_EmailService {
|
|
|
650
650
|
|
|
651
651
|
return propertyKeys;
|
|
652
652
|
} catch (error) {
|
|
653
|
-
throw new
|
|
653
|
+
throw new DynamoFM_Error({
|
|
654
654
|
...this._getDefaultErrorSettings('getTemplatePropertyKeys', error, 'SYSTEM'),
|
|
655
655
|
|
|
656
656
|
errorCode: 'NTS-ES0-GTPK0',
|
|
@@ -662,14 +662,14 @@ export class DynamoNTS_EmailService {
|
|
|
662
662
|
|
|
663
663
|
private _getDefaultErrorSettings(
|
|
664
664
|
fnName: string,
|
|
665
|
-
error:
|
|
665
|
+
error: DynamoFM_AnyError,
|
|
666
666
|
issuer: string
|
|
667
|
-
):
|
|
667
|
+
): DynamoFM_Error_Settings {
|
|
668
668
|
return {
|
|
669
|
-
status: (error as
|
|
669
|
+
status: (error as DynamoFM_Error)?.___status ?? 500,
|
|
670
670
|
message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS; ${this.serviceName})`,
|
|
671
|
-
addECToUserMsg: !(error as
|
|
672
|
-
userMessage: (error as
|
|
671
|
+
addECToUserMsg: !(error as DynamoFM_Error)?.__userMessage,
|
|
672
|
+
userMessage: (error as DynamoFM_Error)?.__userMessage ?? this.defaultErrorUserMsg,
|
|
673
673
|
issuer: issuer,
|
|
674
674
|
issuerService: this.serviceName,
|
|
675
675
|
error: error,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Request, Response } from 'express';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
DynamoFM_Metadata, DynamoFM_DataModel_Params, DynamoFM_Log, DynamoFM_Error, DynamoFM_Array
|
|
7
7
|
} from '@futdevpro/fsm-dynamo';
|
|
8
8
|
import { DynamoNTS_App_Params } from '../../_models/control-models/app-params.control-model';
|
|
9
9
|
|
|
@@ -62,9 +62,9 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
62
62
|
|
|
63
63
|
try {
|
|
64
64
|
this.instance.dbServiceCollection = {};
|
|
65
|
-
set.dbModels?.forEach((dbModel:
|
|
65
|
+
set.dbModels?.forEach((dbModel: DynamoFM_DataModel_Params): void => {
|
|
66
66
|
if (!dbModel.constructed) {
|
|
67
|
-
throw new
|
|
67
|
+
throw new DynamoFM_Error({
|
|
68
68
|
message: `DynamoNTS_GlobalService.setServices failed, ` +
|
|
69
69
|
`ERROR: dbModel is not constructed!`,
|
|
70
70
|
errorCode: 'NTS-GS0-SS1',
|
|
@@ -77,9 +77,9 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
77
77
|
try {
|
|
78
78
|
this.instance.dbServiceCollection[dbModel.dataName] = new DynamoNTS_DBService(dbModel);
|
|
79
79
|
} catch (error) {
|
|
80
|
-
|
|
80
|
+
DynamoFM_Log.error(`Failed to create DynamoNTS_DBService (${dbModel.dataName}).`, error);
|
|
81
81
|
|
|
82
|
-
throw new
|
|
82
|
+
throw new DynamoFM_Error({
|
|
83
83
|
message: `Failed to create DynamoNTS_DBService (${dbModel.dataName}).`,
|
|
84
84
|
issuerService: 'DynamoNTS_GlobalService',
|
|
85
85
|
error: error,
|
|
@@ -92,7 +92,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
92
92
|
|
|
93
93
|
this.instance.authService = set.authService;
|
|
94
94
|
this.instance.emailServiceCollection = set.emailServiceCollection ?? {};
|
|
95
|
-
await
|
|
95
|
+
await DynamoFM_Array.asyncForEach(
|
|
96
96
|
Object.keys(this.instance.emailServiceCollection),
|
|
97
97
|
async (key: string): Promise<void> => {
|
|
98
98
|
await (
|
|
@@ -104,11 +104,11 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
104
104
|
DynamoNTS_GlobalService.globalErrorHandler =
|
|
105
105
|
set.errorHandler ??
|
|
106
106
|
(async (error: any): Promise<void> => {
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
DynamoFM_Log.warn(`globalErrorHandler not set!`);
|
|
108
|
+
DynamoFM_Log.error(`ERROR:\n`, error);
|
|
109
109
|
});
|
|
110
110
|
} catch (error) {
|
|
111
|
-
throw new
|
|
111
|
+
throw new DynamoFM_Error({
|
|
112
112
|
message: `Failed to setServices on DynamoNTS_GlobalService.`,
|
|
113
113
|
error: error,
|
|
114
114
|
errorCode: 'NTS-GS0-SS0',
|
|
@@ -158,8 +158,8 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
158
158
|
* @param dataParams
|
|
159
159
|
* @returns
|
|
160
160
|
*/
|
|
161
|
-
static getDBService<T extends
|
|
162
|
-
dataParams:
|
|
161
|
+
static getDBService<T extends DynamoFM_Metadata>(
|
|
162
|
+
dataParams: DynamoFM_DataModel_Params
|
|
163
163
|
): DynamoNTS_DBService<T> {
|
|
164
164
|
return this.getDBServiceByKey<T>(dataParams.dataName);
|
|
165
165
|
}
|
|
@@ -169,7 +169,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
169
169
|
* @param key
|
|
170
170
|
* @returns
|
|
171
171
|
*/
|
|
172
|
-
static getDBServiceByKey<T extends
|
|
172
|
+
static getDBServiceByKey<T extends DynamoFM_Metadata>(key: string): DynamoNTS_DBService<T> {
|
|
173
173
|
const collection = this.getDBServiceCollection();
|
|
174
174
|
|
|
175
175
|
if (collection[key]) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { DynamoFM_Log } from '@futdevpro/fsm-dynamo';
|
|
4
4
|
import {
|
|
5
5
|
DynamoNTS_Endpoint_Params
|
|
6
6
|
} from '../../_models/control-models/endpoint-params.control-model';
|
|
@@ -84,7 +84,7 @@ export abstract class DynamoNTS_Controller extends DynamoNTS_SingletonService {
|
|
|
84
84
|
try {
|
|
85
85
|
this.setupEndpoints();
|
|
86
86
|
} catch (error) {
|
|
87
|
-
|
|
87
|
+
DynamoFM_Log.error(`DynamoBEController ERROR setup failed:`, error);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { Router } from 'express';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { DynamoFM_Error, DynamoFM_Log } from '@futdevpro/fsm-dynamo';
|
|
5
5
|
|
|
6
6
|
import { DynamoNTS_globalSettings } from '../../_constants/global-settings.const';
|
|
7
7
|
import { DynamoNTS_RouteSecurity } from '../../_enums/route-security.enum';
|
|
@@ -89,7 +89,7 @@ export class DynamoNTS_RoutingModule {
|
|
|
89
89
|
`routing module setup done: ${this.route} serurity: ${this.security}\n`
|
|
90
90
|
);
|
|
91
91
|
} catch (error) {
|
|
92
|
-
|
|
92
|
+
DynamoFM_Log.error(`\nRouting module setup failed (${this.route})`, error);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -116,7 +116,7 @@ export class DynamoNTS_RoutingModule {
|
|
|
116
116
|
endpoint.security = securityOverride;
|
|
117
117
|
} else {
|
|
118
118
|
if (!endpoint.security) {
|
|
119
|
-
|
|
119
|
+
DynamoFM_Log.error(`Endpoint security not set: ${endpoint.endpoint}\n`);
|
|
120
120
|
} else if (!this.security) {
|
|
121
121
|
this.security = endpoint.security;
|
|
122
122
|
} else if (this.security !== endpoint.security) {
|
|
@@ -149,9 +149,9 @@ export class DynamoNTS_RoutingModule {
|
|
|
149
149
|
this.mountSecureRoute(endpoint);
|
|
150
150
|
}
|
|
151
151
|
} catch (error) {
|
|
152
|
-
|
|
152
|
+
DynamoFM_Log.error(`\nRouting module setup failed (${this.route})`, error);
|
|
153
153
|
|
|
154
|
-
throw new
|
|
154
|
+
throw new DynamoFM_Error({
|
|
155
155
|
errorCode: 'NTS-RM9-100',
|
|
156
156
|
addECToUserMsg: true,
|
|
157
157
|
message: `DYNAMO-NTS ERROR: Failed to mount routes.`,
|
|
@@ -191,9 +191,9 @@ export class DynamoNTS_RoutingModule {
|
|
|
191
191
|
break;
|
|
192
192
|
|
|
193
193
|
default:
|
|
194
|
-
|
|
194
|
+
DynamoFM_Log.error(`INVALID route type: ${endpointParams.type} - ${endpointParams.name}`);
|
|
195
195
|
|
|
196
|
-
throw new
|
|
196
|
+
throw new DynamoFM_Error({
|
|
197
197
|
errorCode: 'NTS-RM9-200',
|
|
198
198
|
addECToUserMsg: true,
|
|
199
199
|
message:
|
|
@@ -232,11 +232,11 @@ export class DynamoNTS_RoutingModule {
|
|
|
232
232
|
break;
|
|
233
233
|
|
|
234
234
|
default:
|
|
235
|
-
|
|
235
|
+
DynamoFM_Log.error(
|
|
236
236
|
`DYNAMO-NTS ERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}`
|
|
237
237
|
);
|
|
238
238
|
|
|
239
|
-
throw new
|
|
239
|
+
throw new DynamoFM_Error({
|
|
240
240
|
errorCode: 'NTS-RM9-300',
|
|
241
241
|
addECToUserMsg: true,
|
|
242
242
|
message:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DynamoFM_delay } from '@futdevpro/fsm-dynamo';
|
|
2
2
|
import {
|
|
3
3
|
DynamoNTS_AppExtendedBase_Mock, DynamoNTS_AppExtendedFull_Mock, DynamoNTS_AppWbMock_Mock
|
|
4
4
|
} from '../../_constants/mocks/app-extended-server.mock';
|
|
@@ -10,7 +10,7 @@ describe('DynamoNTS_AppExtended;', (): void => {
|
|
|
10
10
|
beforeEach(async (): Promise<void> => {
|
|
11
11
|
app = new DynamoNTS_AppExtendedBase_Mock();
|
|
12
12
|
|
|
13
|
-
await
|
|
13
|
+
await DynamoFM_delay(100);
|
|
14
14
|
|
|
15
15
|
await app.ready();
|
|
16
16
|
});
|
|
@@ -18,7 +18,7 @@ describe('DynamoNTS_AppExtended;', (): void => {
|
|
|
18
18
|
afterEach(async (): Promise<void> => {
|
|
19
19
|
await app.stop();
|
|
20
20
|
|
|
21
|
-
await
|
|
21
|
+
await DynamoFM_delay(100);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
it('should be created', (): void => {
|
|
@@ -62,7 +62,7 @@ describe('DynamoNTS_AppExtended;', (): void => {
|
|
|
62
62
|
afterEach(async (): Promise<void> => {
|
|
63
63
|
await app.stop();
|
|
64
64
|
|
|
65
|
-
await
|
|
65
|
+
await DynamoFM_delay(100);
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
it('should be created', (): void => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as SocketIO from 'socket.io';
|
|
3
3
|
import * as Http from 'http';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { DynamoFM_Array, DynamoFM_Error, DynamoFM_Log, second, DynamoFM_wait } from '@futdevpro/fsm-dynamo';
|
|
6
6
|
|
|
7
7
|
import { DynamoNTS_App } from './app.server';
|
|
8
8
|
import { DynamoNTS_RouteSecurity } from '../../_enums/route-security.enum';
|
|
@@ -58,8 +58,8 @@ import {
|
|
|
58
58
|
* matchStatisticsModelParams,
|
|
59
59
|
* matchDataModelParams,
|
|
60
60
|
|
|
61
|
-
*
|
|
62
|
-
*
|
|
61
|
+
* DynamoFM_usageSessionModel_params,
|
|
62
|
+
* DynamoFM_customDataModel_params,
|
|
63
63
|
* ]
|
|
64
64
|
* });
|
|
65
65
|
* }
|
|
@@ -139,7 +139,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
139
139
|
super(true);
|
|
140
140
|
|
|
141
141
|
this.asyncConstructExt().catch((error: any): void => {
|
|
142
|
-
|
|
142
|
+
DynamoFM_Log.H_error(
|
|
143
143
|
`\nExtended Application: ${this.params?.name} start failed.` +
|
|
144
144
|
`\n`, error,
|
|
145
145
|
'\n'
|
|
@@ -163,7 +163,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
163
163
|
`\nAll sockets setted up.... sockets using security: ${this.socketSecurity}`
|
|
164
164
|
);
|
|
165
165
|
} else {
|
|
166
|
-
|
|
166
|
+
DynamoFM_Log.testWarn(
|
|
167
167
|
'No socketServices setted up while using Extended Application.',
|
|
168
168
|
'\nYou should use DynamoNTS_App if you don`t need socket services.'
|
|
169
169
|
);
|
|
@@ -175,16 +175,16 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
175
175
|
console.log(this.params.title);
|
|
176
176
|
console.log(`Version: ${this.params.version}`);
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
DynamoFM_Log.H_success(`${this.params.name} started successfully.`);
|
|
179
179
|
|
|
180
180
|
} catch (error) {
|
|
181
|
-
|
|
181
|
+
DynamoFM_Log.H_error(
|
|
182
182
|
`\nExtended Application: ${this.params?.name} start failed.` +
|
|
183
183
|
`\n`, error,
|
|
184
184
|
'\n'
|
|
185
185
|
);
|
|
186
186
|
|
|
187
|
-
throw new
|
|
187
|
+
throw new DynamoFM_Error({
|
|
188
188
|
errorCode: 'NTS-AES-001',
|
|
189
189
|
error: error,
|
|
190
190
|
additionalContent: {
|
|
@@ -213,13 +213,13 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
213
213
|
const start: number = +new Date();
|
|
214
214
|
|
|
215
215
|
if (this.constructErrors.length) {
|
|
216
|
-
|
|
216
|
+
DynamoFM_Log.H_error(
|
|
217
217
|
`Extended Application: ${this.params?.name} start failed. ERRORS`,
|
|
218
218
|
this.constructErrors,
|
|
219
219
|
'\n'
|
|
220
220
|
);
|
|
221
221
|
|
|
222
|
-
throw new
|
|
222
|
+
throw new DynamoFM_Error({
|
|
223
223
|
message: `${this.params?.name} start failed. ERRORS`,
|
|
224
224
|
additionalContent: this.constructErrors,
|
|
225
225
|
error: this.constructErrors?.[0] ?? new Error()
|
|
@@ -234,22 +234,22 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
234
234
|
this.systemControlsExt.httpsSocketServer.getReady()
|
|
235
235
|
);
|
|
236
236
|
} else {
|
|
237
|
-
|
|
237
|
+
DynamoFM_Log.error(`${this.params.name} APP NOT INITIALIZED while trying to get ready.`);
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
if (!ready) {
|
|
241
|
-
await
|
|
241
|
+
await DynamoFM_wait(100);
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
if (this.constructErrors.length) {
|
|
246
|
-
|
|
246
|
+
DynamoFM_Log.H_error(
|
|
247
247
|
`Extended Application: ${this.params?.name} start failed. TIMEOUT`,
|
|
248
248
|
this.constructErrors,
|
|
249
249
|
'\n'
|
|
250
250
|
);
|
|
251
251
|
|
|
252
|
-
throw new
|
|
252
|
+
throw new DynamoFM_Error({
|
|
253
253
|
message: `${this.params?.name} start failed. TIMEOUT`,
|
|
254
254
|
additionalContent: this.constructErrors,
|
|
255
255
|
error: this.constructErrors?.[0] ?? new Error()
|
|
@@ -281,9 +281,9 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
281
281
|
msg += '\nhttpsSocketServer start failed.';
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
|
|
284
|
+
DynamoFM_Log.error(msg, this.constructErrors, '\n');
|
|
285
285
|
|
|
286
|
-
throw new
|
|
286
|
+
throw new DynamoFM_Error({
|
|
287
287
|
errorCode: 'NTS-AES-110',
|
|
288
288
|
message: msg,
|
|
289
289
|
additionalContent: {
|
|
@@ -313,16 +313,16 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
313
313
|
|
|
314
314
|
this.systemControlsExt.httpSocketServer.started = false;
|
|
315
315
|
this.systemControlsExt.httpsSocketServer.started = false;
|
|
316
|
-
await
|
|
316
|
+
await DynamoFM_Array.asyncForEach(
|
|
317
317
|
this.allSocketServers,
|
|
318
318
|
async (socketServer: SocketIO.Server): Promise<void> => {
|
|
319
319
|
await new Promise<void>((resolve, reject): void => {
|
|
320
320
|
socketServer.disconnectSockets(true);
|
|
321
321
|
socketServer.close((err): void => {
|
|
322
322
|
if (err) {
|
|
323
|
-
|
|
323
|
+
DynamoFM_Log.error(`\nHTTP socket server close error`, err);
|
|
324
324
|
reject(
|
|
325
|
-
new
|
|
325
|
+
new DynamoFM_Error({
|
|
326
326
|
errorCode: 'NTS-AES-120',
|
|
327
327
|
message: `SocketServer close failed.`,
|
|
328
328
|
error: err
|
|
@@ -338,7 +338,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
338
338
|
this.systemControlsExt.httpSocketServer.init = false;
|
|
339
339
|
this.systemControlsExt.httpsSocketServer.init = false;
|
|
340
340
|
|
|
341
|
-
|
|
341
|
+
DynamoFM_Log.H_info(`${this.params.name} stopped successfully.`);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
|
|
@@ -404,14 +404,14 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
404
404
|
errorStack.splice(1, 2);
|
|
405
405
|
error.stack = errorStack.join('\n');
|
|
406
406
|
|
|
407
|
-
|
|
407
|
+
DynamoFM_Log.error(errorMsg);
|
|
408
408
|
|
|
409
409
|
throw error;
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
-
await
|
|
414
|
+
await DynamoFM_Array.asyncForEach(
|
|
415
415
|
this.socketServices,
|
|
416
416
|
async (service: DynamoNTS_SocketServerService<any>): Promise<void> => {
|
|
417
417
|
try {
|
|
@@ -431,7 +431,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
431
431
|
errorStack.splice(1, 4);
|
|
432
432
|
error.stack = errorStack.join('\n');
|
|
433
433
|
|
|
434
|
-
|
|
434
|
+
DynamoFM_Log.error(`\n${error.message}`);
|
|
435
435
|
|
|
436
436
|
throw error;
|
|
437
437
|
}
|
|
@@ -487,12 +487,12 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
487
487
|
errorStack.splice(1, 4);
|
|
488
488
|
error.stack = errorStack.join('\n');
|
|
489
489
|
|
|
490
|
-
|
|
490
|
+
DynamoFM_Log.error(`\n${error.message}`);
|
|
491
491
|
|
|
492
492
|
throw error;
|
|
493
493
|
}
|
|
494
494
|
} catch (error) {
|
|
495
|
-
|
|
495
|
+
DynamoFM_Log.error(
|
|
496
496
|
`\nSocket Server service setup failed. (${service?.name})\n`,
|
|
497
497
|
error,
|
|
498
498
|
'\n'
|
|
@@ -503,7 +503,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
503
503
|
}
|
|
504
504
|
);
|
|
505
505
|
} catch (error) {
|
|
506
|
-
|
|
506
|
+
DynamoFM_Log.error(
|
|
507
507
|
`\nSocket Server services setup failed. (${this.socketServices?.length} services)\n`,
|
|
508
508
|
error,
|
|
509
509
|
'\n'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { DynamoFM_Log, DynamoFM_delay } from '@futdevpro/fsm-dynamo';
|
|
3
3
|
import {
|
|
4
4
|
DynamoNTS_AppBase_Mock, DynamoNTS_AppFull_Mock
|
|
5
5
|
} from '../../_constants/mocks/app-server.mock';
|
|
@@ -14,18 +14,18 @@ describe('DynamoNTS_App AND DynamoNTS_AppExtended?;', (): void => {
|
|
|
14
14
|
try {
|
|
15
15
|
app = new DynamoNTS_AppBase_Mock();
|
|
16
16
|
|
|
17
|
-
await
|
|
17
|
+
await DynamoFM_delay(100);
|
|
18
18
|
|
|
19
19
|
await app.ready();
|
|
20
20
|
} catch (error) {
|
|
21
|
-
|
|
21
|
+
DynamoFM_Log.test('error', error);
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
afterEach(async (): Promise<void> => {
|
|
26
26
|
await app.stop();
|
|
27
27
|
|
|
28
|
-
await
|
|
28
|
+
await DynamoFM_delay(100);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
it('should be created', (): void => {
|
|
@@ -45,14 +45,14 @@ describe('DynamoNTS_App AND DynamoNTS_AppExtended?;', (): void => {
|
|
|
45
45
|
app = new DynamoNTS_AppFull_Mock();
|
|
46
46
|
await app.ready();
|
|
47
47
|
} catch (error) {
|
|
48
|
-
|
|
48
|
+
DynamoFM_Log.test('error', error);
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
afterEach(async (): Promise<void> => {
|
|
53
53
|
await app.stop();
|
|
54
54
|
|
|
55
|
-
await
|
|
55
|
+
await DynamoFM_delay(100);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
it('should be created', (): void => {
|