@futdevpro/nts-dynamo 1.7.28 → 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/global-settings.const.d.ts +2 -2
- package/lib/_constants/global-settings.const.d.ts.map +1 -1
- package/lib/_constants/global-settings.const.js +2 -2
- package/lib/_constants/global-settings.const.js.map +1 -1
- package/lib/_constants/mocks/app-extended-server.mock.d.ts +12 -12
- package/lib/_constants/mocks/app-extended-server.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/app-extended-server.mock.js +16 -16
- package/lib/_constants/mocks/app-extended-server.mock.js.map +1 -1
- package/lib/_constants/mocks/app-params.mock.d.ts +2 -2
- package/lib/_constants/mocks/app-params.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/app-params.mock.js +1 -1
- package/lib/_constants/mocks/app-params.mock.js.map +1 -1
- package/lib/_constants/mocks/app-server.mock.d.ts +15 -15
- package/lib/_constants/mocks/app-server.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/app-server.mock.js +10 -10
- 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 +24 -24
- package/lib/_constants/mocks/data-model.mock.js.map +1 -1
- package/lib/_constants/mocks/email-service-collection.mock.d.ts +2 -2
- package/lib/_constants/mocks/email-service-collection.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/email-service-collection.mock.js +1 -1
- package/lib/_constants/mocks/email-service-collection.mock.js.map +1 -1
- package/lib/_constants/mocks/endpoint.mock.d.ts +8 -8
- package/lib/_constants/mocks/endpoint.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/endpoint.mock.js +18 -18
- package/lib/_constants/mocks/endpoint.mock.js.map +1 -1
- package/lib/_constants/mocks/socket-client.mock.d.ts +2 -2
- package/lib/_constants/mocks/socket-client.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/socket-client.mock.js +1 -1
- package/lib/_constants/mocks/socket-client.mock.js.map +1 -1
- package/lib/_constants/mocks/socket-server.mock.d.ts +2 -2
- package/lib/_constants/mocks/socket-server.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/socket-server.mock.js +1 -1
- package/lib/_constants/mocks/socket-server.mock.js.map +1 -1
- package/lib/_enums/data-model-type.enum.d.ts +1 -0
- package/lib/_enums/data-model-type.enum.d.ts.map +1 -1
- package/lib/_enums/data-model-type.enum.js +1 -0
- package/lib/_enums/data-model-type.enum.js.map +1 -1
- package/lib/_models/control-models/api-call-params.control-model.d.ts +3 -3
- package/lib/_models/control-models/api-call-params.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/api-call-params.control-model.js +6 -6
- package/lib/_models/control-models/api-call-params.control-model.js.map +1 -1
- package/lib/_models/control-models/{app-system-controls.control-model copy.d.ts → app-ext-system-controls.control-model.d.ts} +1 -1
- package/lib/_models/control-models/app-ext-system-controls.control-model.d.ts.map +1 -0
- package/lib/_models/control-models/{app-system-controls.control-model copy.js → app-ext-system-controls.control-model.js} +1 -1
- package/lib/_models/control-models/app-ext-system-controls.control-model.js.map +1 -0
- package/lib/_models/control-models/app-params.control-model.d.ts +2 -2
- package/lib/_models/control-models/app-params.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/app-params.control-model.js +3 -3
- package/lib/_models/control-models/app-params.control-model.js.map +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.d.ts +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 +25 -25
- package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/lib/_models/control-models/http-settings.control-model.d.ts +2 -2
- package/lib/_models/control-models/http-settings.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/http-settings.control-model.js +3 -3
- package/lib/_models/control-models/http-settings.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-client-service-params.control-model.d.ts +2 -2
- package/lib/_models/control-models/socket-client-service-params.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/socket-client-service-params.control-model.js +3 -3
- package/lib/_models/control-models/socket-client-service-params.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-event.control-model.js +11 -11
- package/lib/_models/control-models/socket-event.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-presence.control-model.d.ts +12 -0
- package/lib/_models/control-models/socket-presence.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/socket-presence.control-model.js +12 -8
- package/lib/_models/control-models/socket-presence.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-server-service-params.control-model.d.ts +2 -2
- package/lib/_models/control-models/socket-server-service-params.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/socket-server-service-params.control-model.js +4 -4
- package/lib/_models/control-models/socket-server-service-params.control-model.js.map +1 -1
- package/lib/_models/interfaces/certification-settings.interface.d.ts +1 -1
- package/lib/_models/interfaces/certification-settings.interface.d.ts.map +1 -1
- package/lib/_models/interfaces/global-service-settings.interface.d.ts +6 -6
- package/lib/_models/interfaces/global-service-settings.interface.d.ts.map +1 -1
- package/lib/_models/interfaces/global-settings.interface.d.ts +1 -1
- package/lib/_models/interfaces/global-settings.interface.d.ts.map +1 -1
- package/lib/_models/interfaces/routing-module-settings.interface.d.ts +1 -1
- package/lib/_models/interfaces/routing-module-settings.interface.d.ts.map +1 -1
- package/lib/_models/types/db-filter.type.d.ts.map +1 -1
- package/lib/_models/types/db-update.type.d.ts +2 -1
- package/lib/_models/types/db-update.type.d.ts.map +1 -1
- package/lib/_modules/custom-data/custom-data.controller.d.ts +2 -2
- package/lib/_modules/custom-data/custom-data.controller.d.ts.map +1 -1
- package/lib/_modules/custom-data/custom-data.controller.js +18 -16
- 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.d.ts +1 -1
- package/lib/_modules/custom-data/get-custom-data-routing-module.util.d.ts.map +1 -1
- package/lib/_modules/custom-data/get-custom-data-routing-module.util.js +5 -5
- package/lib/_modules/custom-data/get-custom-data-routing-module.util.js.map +1 -1
- package/lib/_modules/test/get-test-routing-module.util.d.ts +1 -1
- package/lib/_modules/test/get-test-routing-module.util.d.ts.map +1 -1
- package/lib/_modules/test/get-test-routing-module.util.js +5 -5
- package/lib/_modules/test/get-test-routing-module.util.js.map +1 -1
- package/lib/_modules/test/test.controller.d.ts +2 -2
- package/lib/_modules/test/test.controller.d.ts.map +1 -1
- package/lib/_modules/test/test.controller.js +33 -33
- package/lib/_modules/test/test.controller.js.map +1 -1
- package/lib/_modules/usage/get-usage-routing-module.util.d.ts +1 -1
- package/lib/_modules/usage/get-usage-routing-module.util.d.ts.map +1 -1
- package/lib/_modules/usage/get-usage-routing-module.util.js +5 -5
- package/lib/_modules/usage/get-usage-routing-module.util.js.map +1 -1
- package/lib/_modules/usage/usage.controller.d.ts +2 -2
- package/lib/_modules/usage/usage.controller.d.ts.map +1 -1
- package/lib/_modules/usage/usage.controller.js +17 -17
- 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 +11 -11
- 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 +50 -50
- 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 +41 -37
- package/lib/_services/base/db.service.js.map +1 -1
- package/lib/_services/core/api.service.d.ts +4 -4
- package/lib/_services/core/api.service.d.ts.map +1 -1
- package/lib/_services/core/api.service.js +34 -34
- 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.d.ts +4 -4
- package/lib/_services/core/email.service.d.ts.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 +13 -13
- package/lib/_services/core/global.service.d.ts.map +1 -1
- package/lib/_services/core/global.service.js +20 -7
- package/lib/_services/core/global.service.js.map +1 -1
- package/lib/_services/core/service-collection.service.d.ts +1 -1
- package/lib/_services/core/service-collection.service.d.ts.map +1 -1
- package/lib/_services/core/service-collection.service.js +3 -3
- package/lib/_services/core/service-collection.service.js.map +1 -1
- package/lib/_services/route/controller.service.d.ts +2 -2
- package/lib/_services/route/controller.service.d.ts.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 +4 -4
- package/lib/_services/route/routing-module.service.d.ts.map +1 -1
- package/lib/_services/route/routing-module.service.js +10 -10
- 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 +27 -27
- 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 +16 -16
- package/lib/_services/server/app.server.d.ts.map +1 -1
- package/lib/_services/server/app.server.js +91 -90
- 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 +2 -2
- package/lib/_services/shared.static-service.js.map +1 -1
- package/lib/_services/socket/socket-client.service.d.ts +3 -3
- package/lib/_services/socket/socket-client.service.d.ts.map +1 -1
- package/lib/_services/socket/socket-client.service.js +35 -29
- package/lib/_services/socket/socket-client.service.js.map +1 -1
- package/lib/_services/socket/socket-server.service.d.ts +3 -3
- package/lib/_services/socket/socket-server.service.d.ts.map +1 -1
- package/lib/_services/socket/socket-server.service.js +51 -51
- 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/global-settings.const.ts +2 -2
- package/src/_constants/mocks/app-extended-server.mock.ts +34 -35
- package/src/_constants/mocks/app-params.mock.ts +2 -2
- package/src/_constants/mocks/app-server.mock.ts +30 -30
- package/src/_constants/mocks/data-model.mock.ts +25 -25
- package/src/_constants/mocks/email-service-collection.mock.ts +2 -2
- package/src/_constants/mocks/endpoint.mock.ts +22 -22
- package/src/_constants/mocks/socket-client.mock.ts +3 -3
- package/src/_constants/mocks/socket-server.mock.ts +3 -3
- package/src/_enums/data-model-type.enum.ts +1 -0
- package/src/_models/control-models/api-call-params.control-model.ts +5 -5
- package/src/_models/control-models/app-params.control-model.ts +2 -2
- package/src/_models/control-models/endpoint-params.control-model.ts +35 -35
- package/src/_models/control-models/http-settings.control-model.ts +2 -2
- package/src/_models/control-models/socket-client-service-params.control-model.ts +2 -2
- package/src/_models/control-models/socket-event.control-model.ts +13 -13
- package/src/_models/control-models/socket-presence.control-model.ts +26 -14
- package/src/_models/control-models/socket-server-service-params.control-model.ts +4 -4
- package/src/_models/interfaces/certification-settings.interface.ts +1 -1
- package/src/_models/interfaces/global-service-settings.interface.ts +6 -6
- package/src/_models/interfaces/global-settings.interface.ts +1 -1
- package/src/_models/interfaces/routing-module-settings.interface.ts +1 -1
- package/src/_models/types/db-filter.type.ts +5 -2
- package/src/_models/types/db-update.type.ts +3 -2
- package/src/_modules/custom-data/custom-data.controller.ts +20 -18
- package/src/_modules/custom-data/custom-data.data-service.ts +8 -6
- package/src/_modules/custom-data/get-custom-data-routing-module.util.ts +7 -7
- package/src/_modules/test/get-test-routing-module.util.ts +7 -7
- package/src/_modules/test/test.controller.ts +34 -34
- package/src/_modules/usage/get-usage-routing-module.util.ts +7 -7
- package/src/_modules/usage/usage.controller.ts +20 -21
- package/src/_modules/usage/usage.data-service.ts +28 -28
- package/src/_services/base/data.service.ts +62 -61
- package/src/_services/base/db.service.ts +53 -50
- package/src/_services/core/api.service.ts +54 -54
- package/src/_services/core/auth.service.ts +9 -9
- package/src/_services/core/email.service.ts +33 -33
- package/src/_services/core/global.service.ts +37 -23
- package/src/_services/core/service-collection.service.ts +1 -1
- package/src/_services/route/controller.service.ts +4 -4
- package/src/_services/route/routing-module.service.ts +21 -21
- package/src/_services/server/app-extended.server.spec.ts +4 -4
- package/src/_services/server/app-extended.server.ts +27 -27
- package/src/_services/server/app.server.spec.ts +6 -6
- package/src/_services/server/app.server.ts +118 -116
- package/src/_services/shared.static-service.ts +8 -5
- package/src/_services/socket/socket-client.service.ts +79 -47
- package/src/_services/socket/socket-server.service.ts +61 -61
- package/tsconfig.json +8 -7
- package/lib/_models/control-models/app-system-controls.control-model copy.d.ts.map +0 -1
- package/lib/_models/control-models/app-system-controls.control-model copy.js.map +0 -1
- /package/src/_models/control-models/{app-system-controls.control-model copy.ts → app-ext-system-controls.control-model.ts} +0 -0
|
@@ -12,27 +12,27 @@ import * as BodyParser from 'body-parser';
|
|
|
12
12
|
/* import { version } from '../../../package.json'; */
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
DynamoFM_AnyError,
|
|
16
|
+
DynamoFM_Array, DynamoFM_Error, DynamoFM_error_defaults,
|
|
17
|
+
DynamoFM_Error_Settings,
|
|
18
|
+
DynamoFM_ErrorLevel, DynamoFM_Log, second, DynamoFM_wait
|
|
19
19
|
} from '@futdevpro/fsm-dynamo';
|
|
20
20
|
|
|
21
21
|
import { DynamoNTS_SingletonService } from '../base/singleton.service';
|
|
22
22
|
import { DynamoNTS_RouteSecurity } from '../../_enums/route-security.enum';
|
|
23
23
|
import { DynamoNTS_RoutingModule } from '../route/routing-module.service';
|
|
24
24
|
import { DynamoNTS_GlobalService } from '../core/global.service';
|
|
25
|
-
import {
|
|
25
|
+
import { DynamoNTS_Http_Settings } from '../../_models/control-models/http-settings.control-model';
|
|
26
26
|
import {
|
|
27
|
-
|
|
27
|
+
DynamoNTS_Certification_Settings
|
|
28
28
|
} from '../../_models/interfaces/certification-settings.interface';
|
|
29
29
|
import {
|
|
30
|
-
|
|
30
|
+
DynamoNTS_GlobalService_Settings
|
|
31
31
|
} from '../../_models/interfaces/global-service-settings.interface';
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
32
|
+
import { DynamoNTS_globalSettings } from '../../_constants/global-settings.const';
|
|
33
|
+
import { DynamoNTS_App_Params } from '../../_models/control-models/app-params.control-model';
|
|
34
34
|
import {
|
|
35
|
-
|
|
35
|
+
DynamoNTS_Endpoint_Params
|
|
36
36
|
} from '../../_models/control-models/endpoint-params.control-model';
|
|
37
37
|
import {
|
|
38
38
|
DynamoNTS_AppSystemControls
|
|
@@ -83,8 +83,8 @@ import {
|
|
|
83
83
|
* matchStatisticsModelParams,
|
|
84
84
|
* matchDataModelParams,
|
|
85
85
|
|
|
86
|
-
*
|
|
87
|
-
*
|
|
86
|
+
* DynamoFM_usageSessionModel_params,
|
|
87
|
+
* DynamoFM_customDataModel_params,
|
|
88
88
|
* ]
|
|
89
89
|
* });
|
|
90
90
|
* }
|
|
@@ -198,6 +198,8 @@ import {
|
|
|
198
198
|
*/
|
|
199
199
|
export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
200
200
|
|
|
201
|
+
// TODO: rename all DynamoNTS_ > DyNTS_ ------------------------------------------------------------------------------------------------------------------------------------
|
|
202
|
+
|
|
201
203
|
protected systemControls: DynamoNTS_AppSystemControls = new DynamoNTS_AppSystemControls();
|
|
202
204
|
get started(): boolean {
|
|
203
205
|
return this.systemControls.app.started;
|
|
@@ -205,7 +207,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
205
207
|
protected get superStarted(): boolean {
|
|
206
208
|
return this.systemControls.app.started;
|
|
207
209
|
}
|
|
208
|
-
protected constructErrors: (Error |
|
|
210
|
+
protected constructErrors: (Error | DynamoFM_Error)[] = [];
|
|
209
211
|
|
|
210
212
|
/* removed since cant use version from package.json
|
|
211
213
|
private readonly _ntsVersion: string = 'v01.07.18';
|
|
@@ -217,8 +219,8 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
217
219
|
return this.params.name;
|
|
218
220
|
}
|
|
219
221
|
|
|
220
|
-
private _params:
|
|
221
|
-
protected get params():
|
|
222
|
+
private _params: DynamoNTS_App_Params;
|
|
223
|
+
protected get params(): DynamoNTS_App_Params {
|
|
222
224
|
return this._params;
|
|
223
225
|
}
|
|
224
226
|
|
|
@@ -229,13 +231,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
229
231
|
return this._security;
|
|
230
232
|
}
|
|
231
233
|
|
|
232
|
-
protected _portSettings:
|
|
233
|
-
protected get portSettings():
|
|
234
|
+
protected _portSettings: DynamoNTS_Http_Settings = new DynamoNTS_Http_Settings();
|
|
235
|
+
protected get portSettings(): DynamoNTS_Http_Settings {
|
|
234
236
|
return this._portSettings;
|
|
235
237
|
}
|
|
236
238
|
|
|
237
|
-
private _cert?:
|
|
238
|
-
protected get cert():
|
|
239
|
+
private _cert?: DynamoNTS_Certification_Settings;
|
|
240
|
+
protected get cert(): DynamoNTS_Certification_Settings {
|
|
239
241
|
return this._cert;
|
|
240
242
|
}
|
|
241
243
|
|
|
@@ -266,29 +268,29 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
266
268
|
super();
|
|
267
269
|
|
|
268
270
|
process.on('unhandledRejection', (reason: object, p_passWhatIsThis: any): void => {
|
|
269
|
-
|
|
271
|
+
DynamoFM_Log.highlightedError(
|
|
270
272
|
'Unhandled Rejection at: ', p_passWhatIsThis,
|
|
271
273
|
'\nRejection reason:', reason
|
|
272
274
|
);
|
|
273
275
|
|
|
274
276
|
try {
|
|
275
277
|
DynamoNTS_GlobalService.globalErrorHandler?.(
|
|
276
|
-
new
|
|
278
|
+
new DynamoFM_Error({
|
|
277
279
|
errorCode: 'NTS-AS0-BASE-UR',
|
|
278
280
|
message: 'Unhandled Rejection!',
|
|
279
281
|
error: new Error(p_passWhatIsThis),
|
|
280
282
|
additionalContent: { reason, p: p_passWhatIsThis },
|
|
281
|
-
level:
|
|
283
|
+
level: DynamoFM_ErrorLevel.critical,
|
|
282
284
|
})
|
|
283
285
|
);
|
|
284
286
|
|
|
285
287
|
} catch (error) {
|
|
286
|
-
|
|
288
|
+
DynamoFM_Log.error('getGlobalErrorHandler ERROR:', error);
|
|
287
289
|
}
|
|
288
290
|
});
|
|
289
291
|
|
|
290
292
|
this.asyncConstruct(extended).catch((error: any): void => {
|
|
291
|
-
|
|
293
|
+
DynamoFM_Log.error(
|
|
292
294
|
`\nApplication: ${this._params.name} start failed.` +
|
|
293
295
|
`\n`, error
|
|
294
296
|
);
|
|
@@ -296,11 +298,11 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
296
298
|
}
|
|
297
299
|
|
|
298
300
|
private async asyncConstruct(extended?: boolean): Promise<void> {
|
|
299
|
-
if (this.logFn && this.deepLog)
|
|
301
|
+
if (this.logFn && this.deepLog) DynamoFM_Log.log('\nfn:. asyncConstruct');
|
|
300
302
|
try {
|
|
301
303
|
this.systemControls.app.init = true;
|
|
302
304
|
this._params = this.getAppParams();
|
|
303
|
-
|
|
305
|
+
DynamoFM_Log.log(
|
|
304
306
|
`\n\n\n\n\n\n\n\n\n\n` +
|
|
305
307
|
`Starting ${this._params?.name}... `
|
|
306
308
|
);
|
|
@@ -315,11 +317,11 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
315
317
|
String.fromCharCode(7)
|
|
316
318
|
);
|
|
317
319
|
|
|
318
|
-
|
|
320
|
+
DynamoFM_error_defaults.issuerSystem = this._params.systemName;
|
|
319
321
|
|
|
320
322
|
this.overrideDynamoNTSGlobalSettings?.();
|
|
321
323
|
|
|
322
|
-
this.logSetup =
|
|
324
|
+
this.logSetup = DynamoNTS_globalSettings.logSetup;
|
|
323
325
|
|
|
324
326
|
this.globalService = DynamoNTS_GlobalService.getInstance();
|
|
325
327
|
await DynamoNTS_GlobalService.setServices(this.getGlobalServiceCollection());
|
|
@@ -356,7 +358,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
356
358
|
}
|
|
357
359
|
|
|
358
360
|
if (this.logSetup) {
|
|
359
|
-
|
|
361
|
+
DynamoFM_Log.log(`\nRoutes mounted.... server using security: ${this._security}`);
|
|
360
362
|
}
|
|
361
363
|
}
|
|
362
364
|
|
|
@@ -371,17 +373,17 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
371
373
|
await this.ready();
|
|
372
374
|
|
|
373
375
|
if (this.params.title) {
|
|
374
|
-
|
|
376
|
+
DynamoFM_Log.success(this.params.title);
|
|
375
377
|
}
|
|
376
|
-
|
|
377
|
-
/*
|
|
378
|
-
|
|
378
|
+
DynamoFM_Log.info(`Version: ${this.params.version}`);
|
|
379
|
+
/* DynamoFM_Log.info(`NTS Version: ${this.ntsVersion}`); */
|
|
380
|
+
DynamoFM_Log.H_success(`${this.params.name} started successfully.`);
|
|
379
381
|
}
|
|
380
382
|
} catch (error) {
|
|
381
383
|
this.constructErrors.push(error);
|
|
382
|
-
|
|
384
|
+
DynamoFM_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
|
|
383
385
|
|
|
384
|
-
throw new
|
|
386
|
+
throw new DynamoFM_Error({
|
|
385
387
|
...this._getDefaultErrorSettings(
|
|
386
388
|
'asyncConstruct',
|
|
387
389
|
error
|
|
@@ -403,14 +405,14 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
403
405
|
}
|
|
404
406
|
|
|
405
407
|
async ready(timeout: number = 4 * second): Promise<void> {
|
|
406
|
-
if (this.logFn)
|
|
408
|
+
if (this.logFn) DynamoFM_Log.log('\nfn:. ready');
|
|
407
409
|
let ready: boolean = false;
|
|
408
410
|
const start: number = +new Date();
|
|
409
411
|
|
|
410
412
|
if (this.constructErrors.length) {
|
|
411
|
-
|
|
413
|
+
DynamoFM_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
|
|
412
414
|
|
|
413
|
-
throw new
|
|
415
|
+
throw new DynamoFM_Error({
|
|
414
416
|
...this._getDefaultErrorSettings(
|
|
415
417
|
'ready',
|
|
416
418
|
new Error(`${this._params.name} start failed. ERRORS`)
|
|
@@ -432,18 +434,18 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
432
434
|
this.systemControls.httpsServer.getReady()
|
|
433
435
|
);
|
|
434
436
|
} else {
|
|
435
|
-
|
|
437
|
+
DynamoFM_Log.error(`${this.params.name} APP NOT INITIALIZED while trying to get ready.`);
|
|
436
438
|
}
|
|
437
439
|
|
|
438
440
|
if (!ready) {
|
|
439
|
-
await
|
|
441
|
+
await DynamoFM_wait(100);
|
|
440
442
|
}
|
|
441
443
|
}
|
|
442
444
|
|
|
443
445
|
if (timeout < +new Date() - start) {
|
|
444
|
-
|
|
446
|
+
DynamoFM_Log.error(`${this._params.name} start failed. TIMEOUT`, this.constructErrors);
|
|
445
447
|
|
|
446
|
-
throw new
|
|
448
|
+
throw new DynamoFM_Error({
|
|
447
449
|
...this._getDefaultErrorSettings(
|
|
448
450
|
'ready',
|
|
449
451
|
new Error(`${this._params.name} start failed. TIMEOUT`)
|
|
@@ -463,9 +465,9 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
463
465
|
}
|
|
464
466
|
|
|
465
467
|
if (this.constructErrors.length) {
|
|
466
|
-
|
|
468
|
+
DynamoFM_Log.error(`${this._params.name} start failed. ERROR`, this.constructErrors);
|
|
467
469
|
|
|
468
|
-
throw new
|
|
470
|
+
throw new DynamoFM_Error({
|
|
469
471
|
...this._getDefaultErrorSettings(
|
|
470
472
|
'ready',
|
|
471
473
|
new Error(`${this._params.name} start failed. ERROR`)
|
|
@@ -479,7 +481,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
479
481
|
if (ready) {
|
|
480
482
|
this.systemControls.app.started = true;
|
|
481
483
|
|
|
482
|
-
if (this.logFn && this.deepLog)
|
|
484
|
+
if (this.logFn && this.deepLog) DynamoFM_Log.log('\nfn:. ready: return');
|
|
483
485
|
|
|
484
486
|
return;
|
|
485
487
|
} else {
|
|
@@ -499,9 +501,9 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
499
501
|
msg += `\nHTTPS Server start failed.`;
|
|
500
502
|
}
|
|
501
503
|
|
|
502
|
-
|
|
504
|
+
DynamoFM_Log.error(msg, this.constructErrors);
|
|
503
505
|
|
|
504
|
-
throw new
|
|
506
|
+
throw new DynamoFM_Error({
|
|
505
507
|
...this._getDefaultErrorSettings(
|
|
506
508
|
'ready',
|
|
507
509
|
new Error(msg)
|
|
@@ -524,14 +526,14 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
524
526
|
}
|
|
525
527
|
|
|
526
528
|
async stop(dontLog?: boolean): Promise<void> {
|
|
527
|
-
|
|
529
|
+
DynamoFM_Log.info('\nstoping server...\n');
|
|
528
530
|
|
|
529
531
|
await this.ready();
|
|
530
532
|
|
|
531
533
|
if (this.started) {
|
|
532
534
|
|
|
533
535
|
if (this.systemControls.mongoose.init) {
|
|
534
|
-
|
|
536
|
+
DynamoFM_Log.info(`\nstopping Mongoose....`);
|
|
535
537
|
|
|
536
538
|
let tryCount: number = 0;
|
|
537
539
|
|
|
@@ -540,13 +542,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
540
542
|
!this.constructErrors.length &&
|
|
541
543
|
tryCount++ < 10
|
|
542
544
|
) {
|
|
543
|
-
|
|
544
|
-
await
|
|
545
|
+
DynamoFM_Log.warn(`Mongoose not even started yet....`);
|
|
546
|
+
await DynamoFM_wait(second);
|
|
545
547
|
}
|
|
546
548
|
this.systemControls.mongoose.started = false;
|
|
547
549
|
|
|
548
550
|
if (this.mongoose) {
|
|
549
|
-
await
|
|
551
|
+
await DynamoFM_Array.asyncForEach(
|
|
550
552
|
Object.keys(this.mongoose.models),
|
|
551
553
|
async (modelName): Promise<void> => {
|
|
552
554
|
await this.mongoose.deleteModel(modelName);
|
|
@@ -567,11 +569,11 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
567
569
|
this.mongoose.connection.readyState !== 0 &&
|
|
568
570
|
!this.constructErrors.length
|
|
569
571
|
) {
|
|
570
|
-
|
|
571
|
-
await
|
|
572
|
+
DynamoFM_Log.warn(`\nMongoose still not disconnected....`);
|
|
573
|
+
await DynamoFM_wait(second);
|
|
572
574
|
}
|
|
573
575
|
} else {
|
|
574
|
-
|
|
576
|
+
DynamoFM_Log.error(`\nMongoose not found.`);
|
|
575
577
|
}
|
|
576
578
|
this.systemControls.mongoose.init = false;
|
|
577
579
|
}
|
|
@@ -584,7 +586,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
584
586
|
this.httpServer.close(resolve);
|
|
585
587
|
});
|
|
586
588
|
} else {
|
|
587
|
-
|
|
589
|
+
DynamoFM_Log.error(`\nHTTP Server not found.`);
|
|
588
590
|
}
|
|
589
591
|
this.systemControls.httpServer.init = false;
|
|
590
592
|
}
|
|
@@ -597,13 +599,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
597
599
|
this.httpsServer.close(resolve);
|
|
598
600
|
});
|
|
599
601
|
} else {
|
|
600
|
-
|
|
602
|
+
DynamoFM_Log.error(`\nHTTPS Server not found.`);
|
|
601
603
|
}
|
|
602
604
|
this.systemControls.httpsServer.init = false;
|
|
603
605
|
}
|
|
604
606
|
|
|
605
607
|
if (!dontLog) {
|
|
606
|
-
|
|
608
|
+
DynamoFM_Log.H_log(`${this._params.name} stopped successfully.`);
|
|
607
609
|
}
|
|
608
610
|
}
|
|
609
611
|
}
|
|
@@ -612,7 +614,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
612
614
|
*
|
|
613
615
|
*/
|
|
614
616
|
private async startDB(): Promise<void> {
|
|
615
|
-
if (this.logFn && this.deepLog)
|
|
617
|
+
if (this.logFn && this.deepLog) DynamoFM_Log.log('\nfn:. startDB');
|
|
616
618
|
|
|
617
619
|
await new Promise<void>(
|
|
618
620
|
(resolve, reject): void => {
|
|
@@ -621,7 +623,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
621
623
|
this.mongoose.connection
|
|
622
624
|
.once('open', (): void => {
|
|
623
625
|
this.systemControls.mongoose.started = true;
|
|
624
|
-
|
|
626
|
+
DynamoFM_Log.success('\nConnected to MongoDB\n');
|
|
625
627
|
|
|
626
628
|
resolve();
|
|
627
629
|
})
|
|
@@ -629,12 +631,12 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
629
631
|
if (!this.systemControls.mongoose.started) {
|
|
630
632
|
this.constructErrors.push(error);
|
|
631
633
|
|
|
632
|
-
if (this.debugLog)
|
|
634
|
+
if (this.debugLog) DynamoFM_Log.error(
|
|
633
635
|
'\nUnable to connect to MongoDB server, ERROR: ',
|
|
634
636
|
error
|
|
635
637
|
);
|
|
636
638
|
|
|
637
|
-
const d_error:
|
|
639
|
+
const d_error: DynamoFM_Error = new DynamoFM_Error({
|
|
638
640
|
...this._getDefaultErrorSettings(
|
|
639
641
|
'startDB',
|
|
640
642
|
error
|
|
@@ -648,9 +650,9 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
648
650
|
reject(d_error);
|
|
649
651
|
|
|
650
652
|
} else {
|
|
651
|
-
if (this.debugLog)
|
|
653
|
+
if (this.debugLog) DynamoFM_Log.error('\nMongoDB ERROR: ', error);
|
|
652
654
|
|
|
653
|
-
const d_error:
|
|
655
|
+
const d_error: DynamoFM_Error = new DynamoFM_Error({
|
|
654
656
|
...this._getDefaultErrorSettings(
|
|
655
657
|
'mongoose.connection.on(error)',
|
|
656
658
|
error
|
|
@@ -658,7 +660,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
658
660
|
|
|
659
661
|
errorCode: 'NTS-AS0-SDB2',
|
|
660
662
|
message: `MongoDB ERROR: ${error}`,
|
|
661
|
-
level:
|
|
663
|
+
level: DynamoFM_ErrorLevel.critical,
|
|
662
664
|
});
|
|
663
665
|
|
|
664
666
|
DynamoNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
@@ -680,7 +682,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
680
682
|
*
|
|
681
683
|
*/
|
|
682
684
|
private async initExpresses(): Promise<void> {
|
|
683
|
-
if (this.logFn && this.deepLog)
|
|
685
|
+
if (this.logFn && this.deepLog) DynamoFM_Log.log('\nfn:. initExpresses');
|
|
684
686
|
|
|
685
687
|
if (this._security && this._security !== DynamoNTS_RouteSecurity.secure) {
|
|
686
688
|
if (!this._portSettings.httpPort) {
|
|
@@ -694,7 +696,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
694
696
|
if (module.security != DynamoNTS_RouteSecurity.secure) {
|
|
695
697
|
errorMsg += `\n ${module.route} (security: ${module.security})`;
|
|
696
698
|
errorMsg += `\n subroutes using open sever:`;
|
|
697
|
-
module.endpoints.forEach((endpoint:
|
|
699
|
+
module.endpoints.forEach((endpoint: DynamoNTS_Endpoint_Params): void => {
|
|
698
700
|
if (endpoint.security != DynamoNTS_RouteSecurity.secure) {
|
|
699
701
|
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
700
702
|
}
|
|
@@ -708,7 +710,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
708
710
|
errorStack.splice(1, 2);
|
|
709
711
|
error.stack = errorStack.join('\n');
|
|
710
712
|
|
|
711
|
-
|
|
713
|
+
DynamoFM_Log.error(errorMsg);
|
|
712
714
|
|
|
713
715
|
throw error;
|
|
714
716
|
}
|
|
@@ -735,7 +737,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
735
737
|
if (module.security && module.security !== DynamoNTS_RouteSecurity.open) {
|
|
736
738
|
errorMsg += `\n ${module.route} (security: ${module.security})`;
|
|
737
739
|
errorMsg += `\n subroutes using secure sever:`;
|
|
738
|
-
module.endpoints.forEach((endpoint:
|
|
740
|
+
module.endpoints.forEach((endpoint: DynamoNTS_Endpoint_Params): void => {
|
|
739
741
|
if (endpoint.security && endpoint.security !== DynamoNTS_RouteSecurity.open) {
|
|
740
742
|
errorMsg += `\n ${endpoint.endpoint} (security: ${endpoint.security})`;
|
|
741
743
|
}
|
|
@@ -749,7 +751,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
749
751
|
errorStack.splice(1, 2);
|
|
750
752
|
error.stack = errorStack.join('\n');
|
|
751
753
|
|
|
752
|
-
|
|
754
|
+
DynamoFM_Log.error(errorMsg);
|
|
753
755
|
|
|
754
756
|
throw error;
|
|
755
757
|
}
|
|
@@ -762,7 +764,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
762
764
|
*
|
|
763
765
|
*/
|
|
764
766
|
protected async initOpenExpress(): Promise<void> {
|
|
765
|
-
if (this.logFn)
|
|
767
|
+
if (this.logFn) DynamoFM_Log.log('\nfn:. initOpenExpress');
|
|
766
768
|
this.openExpress = Express();
|
|
767
769
|
this.openExpress.use(BodyParser.urlencoded(this._portSettings.httpUrlencoded));
|
|
768
770
|
this.openExpress.use(BodyParser.json(this._portSettings.httpJson));
|
|
@@ -772,7 +774,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
772
774
|
*
|
|
773
775
|
*/
|
|
774
776
|
protected async initSecureExpress(): Promise<void> {
|
|
775
|
-
if (this.logFn)
|
|
777
|
+
if (this.logFn) DynamoFM_Log.log('\nfn:. initSecureExpress');
|
|
776
778
|
this.secureExpress = Express();
|
|
777
779
|
this.secureExpress.use(BodyParser.urlencoded(this._portSettings.httpsUrlencoded));
|
|
778
780
|
this.secureExpress.use(BodyParser.json(this._portSettings.httpsJson));
|
|
@@ -789,7 +791,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
789
791
|
*
|
|
790
792
|
*/
|
|
791
793
|
private async startExpresses(): Promise<void> {
|
|
792
|
-
if (this.logFn && this.deepLog)
|
|
794
|
+
if (this.logFn && this.deepLog) DynamoFM_Log.log('\nfn:. startExpresses');
|
|
793
795
|
try {
|
|
794
796
|
if (this._security && this._security !== DynamoNTS_RouteSecurity.open) {
|
|
795
797
|
await new Promise<void>((resolve, reject): void => {
|
|
@@ -797,17 +799,17 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
797
799
|
this.httpsServer
|
|
798
800
|
.listen(this._portSettings.httpsPort, 'localhost', 0, (): void => {
|
|
799
801
|
this.systemControls.httpsServer.started = true;
|
|
800
|
-
|
|
802
|
+
DynamoFM_Log.success(
|
|
801
803
|
`\nHTTPS (secure) server is listening on port: ${this._portSettings.httpsPort}`
|
|
802
804
|
);
|
|
803
805
|
|
|
804
806
|
resolve();
|
|
805
807
|
})
|
|
806
808
|
.on('error', (error): void => {
|
|
807
|
-
if (this.debugLog)
|
|
809
|
+
if (this.debugLog) DynamoFM_Log.error(`\nHTTPS (secure) server ERROR`, error);
|
|
808
810
|
|
|
809
811
|
if (!this.systemControls.httpsServer.started) {
|
|
810
|
-
const d_error:
|
|
812
|
+
const d_error: DynamoFM_Error = new DynamoFM_Error({
|
|
811
813
|
...this._getDefaultErrorSettings(
|
|
812
814
|
'startExpresses',
|
|
813
815
|
error
|
|
@@ -823,7 +825,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
823
825
|
reject(d_error);
|
|
824
826
|
|
|
825
827
|
} else {
|
|
826
|
-
const d_error:
|
|
828
|
+
const d_error: DynamoFM_Error = new DynamoFM_Error({
|
|
827
829
|
...this._getDefaultErrorSettings(
|
|
828
830
|
'httpsServer.on(error)',
|
|
829
831
|
error
|
|
@@ -831,14 +833,14 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
831
833
|
|
|
832
834
|
errorCode: 'NTS-AS0-SE2',
|
|
833
835
|
message: `HTTPS (secure) server ERROR`,
|
|
834
|
-
level:
|
|
836
|
+
level: DynamoFM_ErrorLevel.serious,
|
|
835
837
|
});
|
|
836
838
|
|
|
837
839
|
DynamoNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
838
840
|
}
|
|
839
841
|
})
|
|
840
842
|
.on('uncaughtException', (exception): void => {
|
|
841
|
-
const d_error:
|
|
843
|
+
const d_error: DynamoFM_Error = new DynamoFM_Error({
|
|
842
844
|
...this._getDefaultErrorSettings(
|
|
843
845
|
'httpsServer.on(uncaughtException)',
|
|
844
846
|
exception
|
|
@@ -846,10 +848,10 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
846
848
|
|
|
847
849
|
errorCode: 'NTS-AS0-SE3',
|
|
848
850
|
message: `HTTPS (secure) server uncaughtException`,
|
|
849
|
-
level:
|
|
851
|
+
level: DynamoFM_ErrorLevel.critical,
|
|
850
852
|
});
|
|
851
853
|
|
|
852
|
-
if (this.debugLog)
|
|
854
|
+
if (this.debugLog) DynamoFM_Log.warn(
|
|
853
855
|
`\nHTTPS (secure) server uncaughtException`,
|
|
854
856
|
d_error
|
|
855
857
|
);
|
|
@@ -865,17 +867,17 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
865
867
|
this.httpServer = this.openExpress
|
|
866
868
|
.listen(this._portSettings.httpPort, (): void => {
|
|
867
869
|
this.systemControls.httpServer.started = true;
|
|
868
|
-
|
|
870
|
+
DynamoFM_Log.success(
|
|
869
871
|
`\nHTTP (open) server is listening on port: ${this._portSettings.httpPort}`
|
|
870
872
|
);
|
|
871
873
|
|
|
872
874
|
resolve();
|
|
873
875
|
})
|
|
874
876
|
.on('error', (error): void => {
|
|
875
|
-
if (this.debugLog)
|
|
877
|
+
if (this.debugLog) DynamoFM_Log.error(`\nHTTP (open) server ERROR`, error);
|
|
876
878
|
|
|
877
879
|
if (!this.systemControls.httpServer.started) {
|
|
878
|
-
const d_error:
|
|
880
|
+
const d_error: DynamoFM_Error = new DynamoFM_Error({
|
|
879
881
|
...this._getDefaultErrorSettings(
|
|
880
882
|
'startExpresses',
|
|
881
883
|
error
|
|
@@ -891,7 +893,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
891
893
|
reject(d_error);
|
|
892
894
|
|
|
893
895
|
} else {
|
|
894
|
-
const d_error:
|
|
896
|
+
const d_error: DynamoFM_Error = new DynamoFM_Error({
|
|
895
897
|
...this._getDefaultErrorSettings(
|
|
896
898
|
'httpServer.on(error)',
|
|
897
899
|
error
|
|
@@ -899,14 +901,14 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
899
901
|
|
|
900
902
|
errorCode: 'NTS-AS0-SE4',
|
|
901
903
|
message: `HTTP (open) server ERROR`,
|
|
902
|
-
level:
|
|
904
|
+
level: DynamoFM_ErrorLevel.serious,
|
|
903
905
|
});
|
|
904
906
|
|
|
905
907
|
DynamoNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
906
908
|
}
|
|
907
909
|
})
|
|
908
910
|
.on('uncaughtException', (ex): void => {
|
|
909
|
-
const d_error:
|
|
911
|
+
const d_error: DynamoFM_Error = new DynamoFM_Error({
|
|
910
912
|
...this._getDefaultErrorSettings(
|
|
911
913
|
'httpServer.on(uncaughtException)',
|
|
912
914
|
ex
|
|
@@ -914,17 +916,17 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
914
916
|
|
|
915
917
|
errorCode: 'NTS-AS0-SE5',
|
|
916
918
|
message: `HTTP (open) server uncaughtException`,
|
|
917
|
-
level:
|
|
919
|
+
level: DynamoFM_ErrorLevel.critical,
|
|
918
920
|
});
|
|
919
921
|
|
|
920
|
-
if (this.debugLog)
|
|
922
|
+
if (this.debugLog) DynamoFM_Log.warn(`\nHTTP (open) server uncaughtException`, d_error);
|
|
921
923
|
|
|
922
924
|
DynamoNTS_GlobalService.globalErrorHandler?.(d_error);
|
|
923
925
|
});
|
|
924
926
|
});
|
|
925
927
|
}
|
|
926
928
|
} catch (error) {
|
|
927
|
-
|
|
929
|
+
DynamoFM_Log.error(`startExpresses failed...`, error);
|
|
928
930
|
|
|
929
931
|
throw error;
|
|
930
932
|
}
|
|
@@ -936,7 +938,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
936
938
|
private async expressErrorHandling(error, req, res, next): Promise<void> {
|
|
937
939
|
try {
|
|
938
940
|
if (error) {
|
|
939
|
-
const d_error:
|
|
941
|
+
const d_error: DynamoFM_Error = new DynamoFM_Error({
|
|
940
942
|
...this._getDefaultErrorSettings(
|
|
941
943
|
'expressErrorHandling',
|
|
942
944
|
error
|
|
@@ -948,13 +950,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
948
950
|
req,
|
|
949
951
|
res,
|
|
950
952
|
},
|
|
951
|
-
level:
|
|
953
|
+
level: DynamoFM_ErrorLevel.error,
|
|
952
954
|
});
|
|
953
955
|
|
|
954
956
|
await DynamoNTS_GlobalService.globalErrorHandler?.(d_error, req, res);
|
|
955
957
|
|
|
956
958
|
} else {
|
|
957
|
-
|
|
959
|
+
DynamoFM_Log.H_error(
|
|
958
960
|
'WTF??? express error; without error?...' +
|
|
959
961
|
'\nerr:', error,
|
|
960
962
|
'\nreq:', req,
|
|
@@ -962,7 +964,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
962
964
|
);
|
|
963
965
|
}
|
|
964
966
|
} catch (error) {
|
|
965
|
-
|
|
967
|
+
DynamoFM_Log.H_error(
|
|
966
968
|
'MULTILEVEL ERROR (expressErrorHandling)....' +
|
|
967
969
|
'\n', error
|
|
968
970
|
);
|
|
@@ -973,18 +975,18 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
973
975
|
*
|
|
974
976
|
*/
|
|
975
977
|
private async mountSecureRoutes (): Promise<void> {
|
|
976
|
-
if (this.logFn && this.deepLog)
|
|
978
|
+
if (this.logFn && this.deepLog) DynamoFM_Log.log('\nfn:. mountSecureRoutes');
|
|
977
979
|
|
|
978
980
|
this.openExpress.use(
|
|
979
981
|
(error, req, res, next): Promise<void> => this.expressErrorHandling(error, req, res, next)
|
|
980
982
|
);
|
|
981
983
|
|
|
982
|
-
await
|
|
984
|
+
await DynamoFM_Array.asyncForEach(
|
|
983
985
|
this._routingModules,
|
|
984
986
|
async (module: DynamoNTS_RoutingModule): Promise<void> => {
|
|
985
987
|
if (module.security !== DynamoNTS_RouteSecurity.open) {
|
|
986
988
|
if (this.logSetup) {
|
|
987
|
-
|
|
989
|
+
DynamoFM_Log.log(`route mount (secure): ${module.route}`);
|
|
988
990
|
}
|
|
989
991
|
|
|
990
992
|
const existingRoutes: DynamoNTS_RoutingModule[] = this._routingModules.filter(
|
|
@@ -998,9 +1000,9 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
998
1000
|
errorStack.splice(1, 4);
|
|
999
1001
|
error.stack = errorStack.join('\n');
|
|
1000
1002
|
|
|
1001
|
-
|
|
1003
|
+
DynamoFM_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
1002
1004
|
|
|
1003
|
-
throw new
|
|
1005
|
+
throw new DynamoFM_Error({
|
|
1004
1006
|
...this._getDefaultErrorSettings(
|
|
1005
1007
|
'mountSecureRoutes',
|
|
1006
1008
|
error
|
|
@@ -1021,18 +1023,18 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
1021
1023
|
*
|
|
1022
1024
|
*/
|
|
1023
1025
|
private async mountOpenRoutes(): Promise<void> {
|
|
1024
|
-
if (this.logFn && this.deepLog)
|
|
1026
|
+
if (this.logFn && this.deepLog) DynamoFM_Log.log('\nfn:. mountOpenRoutes');
|
|
1025
1027
|
|
|
1026
1028
|
this.openExpress.use(
|
|
1027
1029
|
(error, req, res, next): Promise<void> => this.expressErrorHandling(error, req, res, next)
|
|
1028
1030
|
);
|
|
1029
1031
|
|
|
1030
|
-
await
|
|
1032
|
+
await DynamoFM_Array.asyncForEach(
|
|
1031
1033
|
this._routingModules,
|
|
1032
1034
|
async (module: DynamoNTS_RoutingModule): Promise<void> => {
|
|
1033
1035
|
if (module.security !== DynamoNTS_RouteSecurity.secure) {
|
|
1034
1036
|
if (this.logSetup) {
|
|
1035
|
-
|
|
1037
|
+
DynamoFM_Log.log(`route mount (open): ${module.route}`);
|
|
1036
1038
|
}
|
|
1037
1039
|
|
|
1038
1040
|
const existingRoutes: DynamoNTS_RoutingModule[] = this._routingModules.filter(
|
|
@@ -1046,9 +1048,9 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
1046
1048
|
errorStack.splice(1, 4);
|
|
1047
1049
|
error.stack = errorStack.join('\n');
|
|
1048
1050
|
|
|
1049
|
-
|
|
1051
|
+
DynamoFM_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
|
|
1050
1052
|
|
|
1051
|
-
throw new
|
|
1053
|
+
throw new DynamoFM_Error({
|
|
1052
1054
|
...this._getDefaultErrorSettings(
|
|
1053
1055
|
'mountOpenRoutes',
|
|
1054
1056
|
error
|
|
@@ -1069,10 +1071,10 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
1069
1071
|
*
|
|
1070
1072
|
*/
|
|
1071
1073
|
private setSecurity(): void {
|
|
1072
|
-
if (this.logFn && this.deepLog)
|
|
1074
|
+
if (this.logFn && this.deepLog) DynamoFM_Log.log('\nfn:. setSecurity');
|
|
1073
1075
|
this._routingModules.forEach((module: DynamoNTS_RoutingModule): void => {
|
|
1074
1076
|
if (!module.security) {
|
|
1075
|
-
|
|
1077
|
+
DynamoFM_Log.warn(`RoutingModule security is not set for ${module.route}\n`);
|
|
1076
1078
|
|
|
1077
1079
|
} else if (!this._security) {
|
|
1078
1080
|
this._security = module.security;
|
|
@@ -1093,36 +1095,36 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
1093
1095
|
if (this._routingModules.length === 0) {
|
|
1094
1096
|
msg += '\n - no RoutingModule found -\n';
|
|
1095
1097
|
}
|
|
1096
|
-
|
|
1098
|
+
DynamoFM_Log.warn(msg);
|
|
1097
1099
|
}
|
|
1098
1100
|
}
|
|
1099
1101
|
|
|
1100
|
-
private _getDefaultErrorSettings(fnName: string, error:
|
|
1102
|
+
private _getDefaultErrorSettings(fnName: string, error: DynamoFM_AnyError): DynamoFM_Error_Settings {
|
|
1101
1103
|
return {
|
|
1102
|
-
status: (error as
|
|
1104
|
+
status: (error as DynamoFM_Error)?.___status ?? 500,
|
|
1103
1105
|
message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS)`,
|
|
1104
|
-
addECToUserMsg: !(error as
|
|
1105
|
-
userMessage: (error as
|
|
1106
|
+
addECToUserMsg: !(error as DynamoFM_Error)?.__userMessage,
|
|
1107
|
+
userMessage: (error as DynamoFM_Error)?.__userMessage ?? this.defaultErrorUserMsg,
|
|
1106
1108
|
issuerService: `${this?.constructor?.name}-DynamoNTS_App`,
|
|
1107
1109
|
error: error,
|
|
1108
|
-
level:
|
|
1110
|
+
level: DynamoFM_ErrorLevel.fatal,
|
|
1109
1111
|
};
|
|
1110
1112
|
}
|
|
1111
1113
|
|
|
1112
1114
|
/**
|
|
1113
1115
|
* MISSING Description (TODO)
|
|
1114
1116
|
*/
|
|
1115
|
-
abstract getAppParams():
|
|
1117
|
+
abstract getAppParams(): DynamoNTS_App_Params;
|
|
1116
1118
|
|
|
1117
1119
|
/**
|
|
1118
1120
|
* MISSING Description (TODO)
|
|
1119
1121
|
*/
|
|
1120
|
-
abstract getGlobalServiceCollection():
|
|
1122
|
+
abstract getGlobalServiceCollection(): DynamoNTS_GlobalService_Settings;
|
|
1121
1123
|
|
|
1122
1124
|
/**
|
|
1123
1125
|
* MISSING Description (TODO)
|
|
1124
1126
|
*/
|
|
1125
|
-
abstract getPortSettings():
|
|
1127
|
+
abstract getPortSettings(): DynamoNTS_Http_Settings;
|
|
1126
1128
|
|
|
1127
1129
|
/**
|
|
1128
1130
|
* MISSING Description (TODO)
|
|
@@ -1142,7 +1144,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
1142
1144
|
/**
|
|
1143
1145
|
* MISSING Description (TODO)
|
|
1144
1146
|
*/
|
|
1145
|
-
getCertificationSettings?():
|
|
1147
|
+
getCertificationSettings?(): DynamoNTS_Certification_Settings;
|
|
1146
1148
|
|
|
1147
1149
|
/**
|
|
1148
1150
|
* MISSING Description (TODO)
|