@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { DynamoFM_Error } from '@futdevpro/fsm-dynamo';
|
|
5
5
|
|
|
6
6
|
import { DynamoNTS_SingletonService } from '../base/singleton.service';
|
|
7
7
|
|
|
@@ -37,7 +37,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
37
37
|
const authHeader = req.headers['authorization'];
|
|
38
38
|
|
|
39
39
|
if (!authHeader) {
|
|
40
|
-
throw new
|
|
40
|
+
throw new DynamoFM_Error({
|
|
41
41
|
status: 401,
|
|
42
42
|
errorCode: 'NTS-AS0-GT0',
|
|
43
43
|
addECToUserMsg: true,
|
|
@@ -50,7 +50,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
50
50
|
const token = authHeader.split(' ')[1];
|
|
51
51
|
|
|
52
52
|
if (!token) {
|
|
53
|
-
throw new
|
|
53
|
+
throw new DynamoFM_Error({
|
|
54
54
|
status: 401,
|
|
55
55
|
errorCode: 'NTS-AS0-GT1',
|
|
56
56
|
addECToUserMsg: true,
|
|
@@ -74,18 +74,18 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
74
74
|
* let token = AuthService.getTokenFromRequest(req);
|
|
75
75
|
* token = await AuthService.verifyToken(token);
|
|
76
76
|
*
|
|
77
|
-
*
|
|
77
|
+
* DynamoFM_Log.success('token authenticated');
|
|
78
78
|
* res.setHeader('authorization', `Bearer ${token}`);
|
|
79
79
|
* next();
|
|
80
80
|
* } catch (error) {
|
|
81
|
-
* error = new
|
|
81
|
+
* error = new DynamoFM_Error({
|
|
82
82
|
* status: 401,
|
|
83
83
|
* message: `authenticateToken (WB-ERROR)`,
|
|
84
84
|
* addECToUserMsg: true,
|
|
85
85
|
* userMessage: `Authorization failed.`,
|
|
86
86
|
* error
|
|
87
87
|
* });
|
|
88
|
-
*
|
|
88
|
+
* DynamoFM_Log.error(error?.message, error);
|
|
89
89
|
*
|
|
90
90
|
* res.status(error.status);
|
|
91
91
|
* res.send(error);
|
|
@@ -108,19 +108,19 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
108
108
|
* try {
|
|
109
109
|
* let token = AuthService.getTokenFromRequest(req);
|
|
110
110
|
* token = await AuthService.verifyTokenSelf(token, req?.params?.userId);
|
|
111
|
-
*
|
|
111
|
+
* DynamoFM_Log.success('selftoken authenticated');
|
|
112
112
|
*
|
|
113
113
|
* res.setHeader('authorization', `Bearer ${token}`);
|
|
114
114
|
* next();
|
|
115
115
|
* } catch (error) {
|
|
116
|
-
* error = new
|
|
116
|
+
* error = new DynamoFM_Error({
|
|
117
117
|
* status: 401,
|
|
118
118
|
* message: `authenticateTokenSelf (WB-ERROR)`,
|
|
119
119
|
* addECToUserMsg: true,
|
|
120
120
|
* userMessage: `Authorization failed.`,
|
|
121
121
|
* error
|
|
122
122
|
* });
|
|
123
|
-
*
|
|
123
|
+
* DynamoFM_Log.error(error?.message, error);
|
|
124
124
|
*
|
|
125
125
|
* res.status(error.status);
|
|
126
126
|
* res.send(error);
|
|
@@ -5,9 +5,9 @@ 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
|
-
export interface
|
|
10
|
+
export interface DynamoNTS_EmailService_Settings {
|
|
11
11
|
host: string,
|
|
12
12
|
port: number,
|
|
13
13
|
email: string,
|
|
@@ -41,7 +41,7 @@ export class DynamoNTS_EmailTemplateComponent {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export interface
|
|
44
|
+
export interface DynamoNTS_SendEmail_Settings<T = { [propertyKey: string]: string; }> {
|
|
45
45
|
to: string;
|
|
46
46
|
subject: string;
|
|
47
47
|
/** direct email content, if provided, this will be used */
|
|
@@ -78,7 +78,7 @@ export class DynamoNTS_EmailService {
|
|
|
78
78
|
`\nplease contact the responsible development team.`;
|
|
79
79
|
|
|
80
80
|
constructor (
|
|
81
|
-
set:
|
|
81
|
+
set: DynamoNTS_EmailService_Settings
|
|
82
82
|
) {
|
|
83
83
|
this.serviceName = this.constructor?.name;
|
|
84
84
|
this.senderName = set.senderName;
|
|
@@ -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',
|
|
@@ -126,7 +126,7 @@ export class DynamoNTS_EmailService {
|
|
|
126
126
|
* @param set
|
|
127
127
|
*/
|
|
128
128
|
public async sendEmail<T>(
|
|
129
|
-
set:
|
|
129
|
+
set: DynamoNTS_SendEmail_Settings<T>,
|
|
130
130
|
issuer: string
|
|
131
131
|
): Promise<void> {
|
|
132
132
|
try {
|
|
@@ -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,19 +3,19 @@
|
|
|
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
|
-
import {
|
|
8
|
+
import { DynamoNTS_App_Params } from '../../_models/control-models/app-params.control-model';
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
|
|
11
|
+
DynamoNTS_GlobalService_Settings
|
|
12
12
|
} from '../../_models/interfaces/global-service-settings.interface';
|
|
13
13
|
|
|
14
14
|
import { DynamoNTS_AuthService } from './auth.service';
|
|
15
15
|
/* import { DynamoNTS_DBServiceCollection } from './db-service-collection.service'; */
|
|
16
16
|
import { DynamoNTS_DBService } from '../base/db.service';
|
|
17
17
|
import { DynamoNTS_EmailService } from './email.service';
|
|
18
|
-
import {
|
|
18
|
+
import { DynamoNTS_Service_Collection } from './service-collection.service';
|
|
19
19
|
/* import { DynamoNTS_EmailServiceCollection } from './email-service-collection.service'; */
|
|
20
20
|
import { DynamoNTS_SingletonService } from '../base/singleton.service';
|
|
21
21
|
|
|
@@ -30,8 +30,8 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
30
30
|
return DynamoNTS_GlobalService.getSingletonInstance();
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
private static _params:
|
|
34
|
-
static get params():
|
|
33
|
+
private static _params: DynamoNTS_App_Params;
|
|
34
|
+
static get params(): DynamoNTS_App_Params {
|
|
35
35
|
return this._params;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -44,8 +44,8 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
authService: DynamoNTS_AuthService;
|
|
47
|
-
dbServiceCollection:
|
|
48
|
-
emailServiceCollection:
|
|
47
|
+
dbServiceCollection: DynamoNTS_Service_Collection<DynamoNTS_DBService<any>>;
|
|
48
|
+
emailServiceCollection: DynamoNTS_Service_Collection<DynamoNTS_EmailService>;
|
|
49
49
|
|
|
50
50
|
static globalErrorHandler?: (
|
|
51
51
|
err: any,
|
|
@@ -57,28 +57,42 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
57
57
|
/**
|
|
58
58
|
* You need to setup global Services through this function
|
|
59
59
|
*/
|
|
60
|
-
static async setServices(set:
|
|
60
|
+
static async setServices(set: DynamoNTS_GlobalService_Settings): Promise<void> {
|
|
61
61
|
this.getInstance();
|
|
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
|
+
if (!dbModel.constructed) {
|
|
67
|
+
throw new DynamoFM_Error({
|
|
68
|
+
message: `DynamoNTS_GlobalService.setServices failed, ` +
|
|
69
|
+
`ERROR: dbModel is not constructed!`,
|
|
70
|
+
errorCode: 'NTS-GS0-SS1',
|
|
71
|
+
additionalContent: {
|
|
72
|
+
dbModel: dbModel,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
66
77
|
try {
|
|
67
78
|
this.instance.dbServiceCollection[dbModel.dataName] = new DynamoNTS_DBService(dbModel);
|
|
68
79
|
} catch (error) {
|
|
69
|
-
|
|
80
|
+
DynamoFM_Log.error(`Failed to create DynamoNTS_DBService (${dbModel.dataName}).`, error);
|
|
70
81
|
|
|
71
|
-
throw new
|
|
72
|
-
message: `Failed to create DynamoNTS_DBService (${dbModel.dataName})
|
|
82
|
+
throw new DynamoFM_Error({
|
|
83
|
+
message: `Failed to create DynamoNTS_DBService (${dbModel.dataName}).`,
|
|
73
84
|
issuerService: 'DynamoNTS_GlobalService',
|
|
74
85
|
error: error,
|
|
86
|
+
additionalContent: {
|
|
87
|
+
dbModel: dbModel,
|
|
88
|
+
},
|
|
75
89
|
});
|
|
76
90
|
}
|
|
77
91
|
});
|
|
78
92
|
|
|
79
93
|
this.instance.authService = set.authService;
|
|
80
94
|
this.instance.emailServiceCollection = set.emailServiceCollection ?? {};
|
|
81
|
-
await
|
|
95
|
+
await DynamoFM_Array.asyncForEach(
|
|
82
96
|
Object.keys(this.instance.emailServiceCollection),
|
|
83
97
|
async (key: string): Promise<void> => {
|
|
84
98
|
await (
|
|
@@ -90,11 +104,11 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
90
104
|
DynamoNTS_GlobalService.globalErrorHandler =
|
|
91
105
|
set.errorHandler ??
|
|
92
106
|
(async (error: any): Promise<void> => {
|
|
93
|
-
|
|
94
|
-
|
|
107
|
+
DynamoFM_Log.warn(`globalErrorHandler not set!`);
|
|
108
|
+
DynamoFM_Log.error(`ERROR:\n`, error);
|
|
95
109
|
});
|
|
96
110
|
} catch (error) {
|
|
97
|
-
throw new
|
|
111
|
+
throw new DynamoFM_Error({
|
|
98
112
|
message: `Failed to setServices on DynamoNTS_GlobalService.`,
|
|
99
113
|
error: error,
|
|
100
114
|
errorCode: 'NTS-GS0-SS0',
|
|
@@ -102,7 +116,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
102
116
|
}
|
|
103
117
|
}
|
|
104
118
|
|
|
105
|
-
static setParams(params:
|
|
119
|
+
static setParams(params: DynamoNTS_App_Params): void {
|
|
106
120
|
this._params = params;
|
|
107
121
|
}
|
|
108
122
|
|
|
@@ -126,7 +140,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
126
140
|
*
|
|
127
141
|
* @returns
|
|
128
142
|
*/
|
|
129
|
-
static getDBServiceCollection():
|
|
143
|
+
static getDBServiceCollection(): DynamoNTS_Service_Collection<DynamoNTS_DBService<any>> {
|
|
130
144
|
if (!this.instance?.dbServiceCollection) {
|
|
131
145
|
throw new Error(
|
|
132
146
|
`\n Unique DataBase Service Collection missing!` +
|
|
@@ -144,8 +158,8 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
144
158
|
* @param dataParams
|
|
145
159
|
* @returns
|
|
146
160
|
*/
|
|
147
|
-
static getDBService<T extends
|
|
148
|
-
dataParams:
|
|
161
|
+
static getDBService<T extends DynamoFM_Metadata>(
|
|
162
|
+
dataParams: DynamoFM_DataModel_Params
|
|
149
163
|
): DynamoNTS_DBService<T> {
|
|
150
164
|
return this.getDBServiceByKey<T>(dataParams.dataName);
|
|
151
165
|
}
|
|
@@ -155,7 +169,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
155
169
|
* @param key
|
|
156
170
|
* @returns
|
|
157
171
|
*/
|
|
158
|
-
static getDBServiceByKey<T extends
|
|
172
|
+
static getDBServiceByKey<T extends DynamoFM_Metadata>(key: string): DynamoNTS_DBService<T> {
|
|
159
173
|
const collection = this.getDBServiceCollection();
|
|
160
174
|
|
|
161
175
|
if (collection[key]) {
|
|
@@ -178,7 +192,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
178
192
|
*
|
|
179
193
|
* @returns
|
|
180
194
|
*/
|
|
181
|
-
static getEmailServiceCollection():
|
|
195
|
+
static getEmailServiceCollection(): DynamoNTS_Service_Collection<DynamoNTS_EmailService> {
|
|
182
196
|
if (!this.instance?.emailServiceCollection) {
|
|
183
197
|
throw new Error(
|
|
184
198
|
`\n Unique Email Service Collection missing!` +
|
|
@@ -1,8 +1,8 @@
|
|
|
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';
|
|
7
7
|
|
|
8
8
|
import { DynamoNTS_SingletonService } from '../base/singleton.service';
|
|
@@ -76,7 +76,7 @@ export abstract class DynamoNTS_Controller extends DynamoNTS_SingletonService {
|
|
|
76
76
|
* }),
|
|
77
77
|
* ];
|
|
78
78
|
*/
|
|
79
|
-
endpoints:
|
|
79
|
+
endpoints: DynamoNTS_Endpoint_Params[];
|
|
80
80
|
|
|
81
81
|
protected constructor(){
|
|
82
82
|
super();
|
|
@@ -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,17 +1,17 @@
|
|
|
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
|
-
import {
|
|
6
|
+
import { DynamoNTS_globalSettings } from '../../_constants/global-settings.const';
|
|
7
7
|
import { DynamoNTS_RouteSecurity } from '../../_enums/route-security.enum';
|
|
8
8
|
import { DynamoNTS_HttpCallType } from '../../_enums/http/http-call-type.enum';
|
|
9
9
|
import { DynamoNTS_Controller } from './controller.service';
|
|
10
10
|
import {
|
|
11
|
-
|
|
11
|
+
DynamoNTS_RoutingModule_Settings
|
|
12
12
|
} from '../../_models/interfaces/routing-module-settings.interface';
|
|
13
13
|
import {
|
|
14
|
-
|
|
14
|
+
DynamoNTS_Endpoint_Params
|
|
15
15
|
} from '../../_models/control-models/endpoint-params.control-model';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -64,23 +64,23 @@ export class DynamoNTS_RoutingModule {
|
|
|
64
64
|
route: string;
|
|
65
65
|
|
|
66
66
|
private controllers: DynamoNTS_Controller[];
|
|
67
|
-
endpoints:
|
|
67
|
+
endpoints: DynamoNTS_Endpoint_Params[] = [];
|
|
68
68
|
|
|
69
69
|
openRouter: Router = Router();
|
|
70
70
|
secureRouter: Router = Router();
|
|
71
71
|
|
|
72
|
-
protected log: boolean =
|
|
72
|
+
protected log: boolean = DynamoNTS_globalSettings.logSetup;
|
|
73
73
|
|
|
74
74
|
defaultErrorUserMsg =
|
|
75
75
|
`We encountered an uncought BackEnd Build Error, ` +
|
|
76
76
|
`\nplease contact the responsible development team.`;
|
|
77
77
|
|
|
78
78
|
constructor(
|
|
79
|
-
set:
|
|
79
|
+
set: DynamoNTS_RoutingModule_Settings
|
|
80
80
|
){
|
|
81
81
|
try {
|
|
82
82
|
this.serviceName = set.route.replace('/', '') + 'RoutingModule';
|
|
83
|
-
this.route =
|
|
83
|
+
this.route = DynamoNTS_globalSettings.baseUrl + set.route;
|
|
84
84
|
this.controllers = set.controllers ?? [];
|
|
85
85
|
this.setupRoutes();
|
|
86
86
|
this.mountRoutes(set.securityOverride);
|
|
@@ -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
|
|
|
@@ -111,12 +111,12 @@ export class DynamoNTS_RoutingModule {
|
|
|
111
111
|
this.security = securityOverride;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
this.endpoints.forEach((endpoint:
|
|
114
|
+
this.endpoints.forEach((endpoint: DynamoNTS_Endpoint_Params): void => {
|
|
115
115
|
if (securityOverride) {
|
|
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) {
|
|
@@ -127,8 +127,8 @@ export class DynamoNTS_RoutingModule {
|
|
|
127
127
|
if (this.log) console.log(
|
|
128
128
|
`endpoint mount (${endpoint.security}): ${this.route}${endpoint.endpoint}`
|
|
129
129
|
);
|
|
130
|
-
const existingEndPoints:
|
|
131
|
-
.filter((ep:
|
|
130
|
+
const existingEndPoints: DynamoNTS_Endpoint_Params[] = this.endpoints
|
|
131
|
+
.filter((ep: DynamoNTS_Endpoint_Params): boolean => ep.endpoint === endpoint.endpoint);
|
|
132
132
|
|
|
133
133
|
if (1 < existingEndPoints.length) {
|
|
134
134
|
const error = new Error(`ENDPOINT DUPLICATION: ${endpoint.endpoint}`);
|
|
@@ -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.`,
|
|
@@ -167,7 +167,7 @@ export class DynamoNTS_RoutingModule {
|
|
|
167
167
|
*
|
|
168
168
|
* @param endpointParams
|
|
169
169
|
*/
|
|
170
|
-
private mountOpenRoute(endpointParams:
|
|
170
|
+
private mountOpenRoute(endpointParams: DynamoNTS_Endpoint_Params): void {
|
|
171
171
|
switch(endpointParams.type) {
|
|
172
172
|
|
|
173
173
|
case DynamoNTS_HttpCallType.get:
|
|
@@ -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:
|
|
@@ -209,7 +209,7 @@ export class DynamoNTS_RoutingModule {
|
|
|
209
209
|
*
|
|
210
210
|
* @param endpointParams
|
|
211
211
|
*/
|
|
212
|
-
private mountSecureRoute(endpointParams:
|
|
212
|
+
private mountSecureRoute(endpointParams: DynamoNTS_Endpoint_Params): void {
|
|
213
213
|
switch(endpointParams.type) {
|
|
214
214
|
case DynamoNTS_HttpCallType.get:
|
|
215
215
|
this.secureRouter.get(endpointParams.endpoint, endpointParams.getFullExecution());
|
|
@@ -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:
|