@futdevpro/nts-dynamo 1.8.5 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.copilot/patterns.json +1 -1
- package/.eslintrc.json +9 -1
- package/lib/_constants/mocks/app-extended-server.mock.js +5 -5
- package/lib/_constants/mocks/app-extended-server.mock.js.map +1 -1
- package/lib/_constants/mocks/app-server.mock.js +4 -4
- package/lib/_constants/mocks/app-server.mock.js.map +1 -1
- package/lib/_constants/mocks/data-model.mock.d.ts +5 -5
- package/lib/_constants/mocks/data-model.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/data-model.mock.js +4 -4
- package/lib/_constants/mocks/data-model.mock.js.map +1 -1
- package/lib/_constants/mocks/endpoint.mock.d.ts.map +1 -1
- package/lib/_constants/mocks/endpoint.mock.js.map +1 -1
- package/lib/_models/control-models/api-call-params.control-model.js +1 -1
- package/lib/_models/control-models/api-call-params.control-model.js.map +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.js +19 -18
- package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-event.control-model.js +7 -7
- package/lib/_models/control-models/socket-event.control-model.js.map +1 -1
- package/lib/_models/control-models/socket-presence.control-model.js +8 -8
- package/lib/_models/control-models/socket-presence.control-model.js.map +1 -1
- package/lib/_models/interfaces/global-service-settings.interface.d.ts +3 -3
- package/lib/_models/interfaces/global-service-settings.interface.d.ts.map +1 -1
- package/lib/_modules/custom-data/custom-data.controller.js +4 -4
- package/lib/_modules/custom-data/custom-data.controller.js.map +1 -1
- package/lib/_modules/custom-data/custom-data.data-service.d.ts +3 -3
- package/lib/_modules/custom-data/custom-data.data-service.d.ts.map +1 -1
- package/lib/_modules/custom-data/custom-data.data-service.js +4 -4
- package/lib/_modules/custom-data/custom-data.data-service.js.map +1 -1
- package/lib/_modules/custom-data/get-custom-data-routing-module.util.js +1 -1
- package/lib/_modules/custom-data/get-custom-data-routing-module.util.js.map +1 -1
- package/lib/_modules/test/get-test-routing-module.util.js +1 -1
- package/lib/_modules/test/get-test-routing-module.util.js.map +1 -1
- package/lib/_modules/test/test.controller.js +6 -6
- package/lib/_modules/test/test.controller.js.map +1 -1
- package/lib/_modules/usage/get-usage-routing-module.util.js +1 -1
- package/lib/_modules/usage/get-usage-routing-module.util.js.map +1 -1
- package/lib/_modules/usage/usage.controller.js +5 -5
- package/lib/_modules/usage/usage.controller.js.map +1 -1
- package/lib/_modules/usage/usage.data-service.d.ts +8 -8
- package/lib/_modules/usage/usage.data-service.d.ts.map +1 -1
- package/lib/_modules/usage/usage.data-service.js +8 -8
- package/lib/_modules/usage/usage.data-service.js.map +1 -1
- package/lib/_services/base/data.service.d.ts +4 -4
- package/lib/_services/base/data.service.d.ts.map +1 -1
- package/lib/_services/base/data.service.js +35 -35
- package/lib/_services/base/data.service.js.map +1 -1
- package/lib/_services/base/db.service.d.ts +6 -6
- package/lib/_services/base/db.service.d.ts.map +1 -1
- package/lib/_services/base/db.service.js +31 -31
- package/lib/_services/base/db.service.js.map +1 -1
- package/lib/_services/core/api.service.js +25 -25
- package/lib/_services/core/api.service.js.map +1 -1
- package/lib/_services/core/auth.service.d.ts +6 -6
- package/lib/_services/core/auth.service.js +2 -2
- package/lib/_services/core/auth.service.js.map +1 -1
- package/lib/_services/core/email.service.js +23 -23
- package/lib/_services/core/email.service.js.map +1 -1
- package/lib/_services/core/global.service.d.ts +3 -3
- package/lib/_services/core/global.service.d.ts.map +1 -1
- package/lib/_services/core/global.service.js +7 -7
- package/lib/_services/core/global.service.js.map +1 -1
- package/lib/_services/route/controller.service.js +1 -1
- package/lib/_services/route/controller.service.js.map +1 -1
- package/lib/_services/route/routing-module.service.d.ts.map +1 -1
- package/lib/_services/route/routing-module.service.js +23 -12
- package/lib/_services/route/routing-module.service.js.map +1 -1
- package/lib/_services/server/app-extended.server.d.ts +2 -2
- package/lib/_services/server/app-extended.server.js +25 -25
- package/lib/_services/server/app-extended.server.js.map +1 -1
- package/lib/_services/server/app-extended.server.spec.js +3 -3
- package/lib/_services/server/app-extended.server.spec.js.map +1 -1
- package/lib/_services/server/app.server.d.ts +4 -4
- package/lib/_services/server/app.server.d.ts.map +1 -1
- package/lib/_services/server/app.server.js +89 -88
- package/lib/_services/server/app.server.js.map +1 -1
- package/lib/_services/server/app.server.spec.js +5 -5
- package/lib/_services/server/app.server.spec.js.map +1 -1
- package/lib/_services/shared.static-service.d.ts +4 -4
- package/lib/_services/shared.static-service.d.ts.map +1 -1
- package/lib/_services/shared.static-service.js +1 -1
- package/lib/_services/shared.static-service.js.map +1 -1
- package/lib/_services/socket/socket-client.service.js +19 -19
- package/lib/_services/socket/socket-client.service.js.map +1 -1
- package/lib/_services/socket/socket-server.service.js +46 -46
- package/lib/_services/socket/socket-server.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +233 -230
- package/src/_constants/mocks/app-extended-server.mock.ts +8 -8
- package/src/_constants/mocks/app-server.mock.ts +6 -6
- package/src/_constants/mocks/data-model.mock.ts +5 -5
- package/src/_constants/mocks/endpoint.mock.ts +50 -47
- package/src/_models/control-models/api-call-params.control-model.ts +2 -2
- package/src/_models/control-models/endpoint-params.control-model.ts +30 -29
- package/src/_models/control-models/socket-event.control-model.ts +8 -8
- package/src/_models/control-models/socket-presence.control-model.ts +14 -14
- package/src/_models/interfaces/global-service-settings.interface.ts +3 -3
- package/src/_modules/custom-data/custom-data.controller.ts +6 -6
- package/src/_modules/custom-data/custom-data.data-service.ts +5 -5
- package/src/_modules/custom-data/get-custom-data-routing-module.util.ts +2 -2
- package/src/_modules/test/get-test-routing-module.util.ts +2 -2
- package/src/_modules/test/test.controller.ts +7 -7
- package/src/_modules/usage/get-usage-routing-module.util.ts +2 -2
- package/src/_modules/usage/usage.controller.ts +7 -7
- package/src/_modules/usage/usage.data-service.ts +28 -28
- package/src/_services/base/data.service.ts +46 -46
- package/src/_services/base/db.service.ts +45 -45
- package/src/_services/core/api.service.ts +32 -32
- package/src/_services/core/auth.service.ts +9 -9
- package/src/_services/core/email.service.ts +29 -29
- package/src/_services/core/global.service.ts +12 -12
- package/src/_services/route/controller.service.ts +2 -2
- package/src/_services/route/routing-module.service.ts +26 -16
- package/src/_services/server/app-extended.server.spec.ts +4 -4
- package/src/_services/server/app-extended.server.ts +26 -26
- package/src/_services/server/app.server.spec.ts +6 -6
- package/src/_services/server/app.server.ts +99 -97
- package/src/_services/shared.static-service.ts +4 -4
- package/src/_services/socket/socket-client.service.ts +21 -21
- package/src/_services/socket/socket-server.service.ts +52 -52
- package/tsconfig.json +7 -7
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
|
|
1
2
|
import { DynamoNTS_HttpCallType } from '../../_enums';
|
|
2
3
|
import { DynamoNTS_Endpoint_Params } from '../../_models';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
5
|
+
export const DynamoNTS_endpointBase_mock: DynamoNTS_Endpoint_Params =
|
|
6
|
+
new DynamoNTS_Endpoint_Params({
|
|
7
|
+
name: 'testBase',
|
|
8
|
+
type: DynamoNTS_HttpCallType.get,
|
|
9
|
+
endpoint: '/test-base',
|
|
10
|
+
preProcessess: [],
|
|
11
|
+
tasks: [
|
|
12
|
+
async (req, res): Promise<void> => {
|
|
13
|
+
res.send('test-base');
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
17
|
|
|
18
18
|
export const DynamoNTS_endpointSimple_mock: DynamoNTS_Endpoint_Params =
|
|
19
19
|
new DynamoNTS_Endpoint_Params({
|
|
@@ -28,29 +28,31 @@ export const DynamoNTS_endpointSimple_mock: DynamoNTS_Endpoint_Params =
|
|
|
28
28
|
],
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
export const DynamoNTS_endpointPost_mock: DynamoNTS_Endpoint_Params =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
res
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
export const DynamoNTS_endpointPost_mock: DynamoNTS_Endpoint_Params =
|
|
32
|
+
new DynamoNTS_Endpoint_Params({
|
|
33
|
+
name: 'testPost',
|
|
34
|
+
type: DynamoNTS_HttpCallType.post,
|
|
35
|
+
endpoint: '/test-post',
|
|
36
|
+
preProcessess: [],
|
|
37
|
+
tasks: [
|
|
38
|
+
async (req, res): Promise<void> => {
|
|
39
|
+
res.send('test-post');
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
});
|
|
42
43
|
|
|
43
|
-
export const DynamoNTS_endpointPut_mock: DynamoNTS_Endpoint_Params =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
res
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
export const DynamoNTS_endpointPut_mock: DynamoNTS_Endpoint_Params =
|
|
45
|
+
new DynamoNTS_Endpoint_Params({
|
|
46
|
+
name: 'testPut',
|
|
47
|
+
type: DynamoNTS_HttpCallType.put,
|
|
48
|
+
endpoint: '/test-put',
|
|
49
|
+
preProcessess: [],
|
|
50
|
+
tasks: [
|
|
51
|
+
async (req, res): Promise<void> => {
|
|
52
|
+
res.send('test-put');
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
});
|
|
54
56
|
|
|
55
57
|
export const DynamoNTS_endpointDelete_mock: DynamoNTS_Endpoint_Params =
|
|
56
58
|
new DynamoNTS_Endpoint_Params({
|
|
@@ -65,17 +67,18 @@ export const DynamoNTS_endpointDelete_mock: DynamoNTS_Endpoint_Params =
|
|
|
65
67
|
],
|
|
66
68
|
});
|
|
67
69
|
|
|
68
|
-
export const DynamoNTS_endpointThrow_mock: DynamoNTS_Endpoint_Params =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
export const DynamoNTS_endpointThrow_mock: DynamoNTS_Endpoint_Params =
|
|
71
|
+
new DynamoNTS_Endpoint_Params({
|
|
72
|
+
name: 'testThrow',
|
|
73
|
+
type: DynamoNTS_HttpCallType.get,
|
|
74
|
+
endpoint: '/test-throw',
|
|
75
|
+
preProcessess: [],
|
|
76
|
+
tasks: [
|
|
77
|
+
async (req, res): Promise<void> => {
|
|
78
|
+
throw new Error('test-throw');
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
});
|
|
79
82
|
|
|
80
83
|
export const DynamoNTS_endpoints_mock: DynamoNTS_Endpoint_Params[] = [
|
|
81
84
|
DynamoNTS_endpointBase_mock,
|
|
@@ -84,4 +87,4 @@ export const DynamoNTS_endpoints_mock: DynamoNTS_Endpoint_Params[] = [
|
|
|
84
87
|
DynamoNTS_endpointPut_mock,
|
|
85
88
|
DynamoNTS_endpointDelete_mock,
|
|
86
89
|
DynamoNTS_endpointThrow_mock,
|
|
87
|
-
];
|
|
90
|
+
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { DynamoFM_Log } from '@futdevpro/fsm-dynamo';
|
|
3
3
|
import { DynamoNTS_HttpCallType } from '../../_enums/http/http-call-type.enum';
|
|
4
4
|
import { DynamoNTS_HttpResponseType } from '../../_enums/http/http-response-type.enum';
|
|
5
5
|
|
|
@@ -78,7 +78,7 @@ export class DynamoNTS_ApiCall_Params {
|
|
|
78
78
|
this.type = set.type;
|
|
79
79
|
|
|
80
80
|
if (set.endPoint.includes('{')) {
|
|
81
|
-
|
|
81
|
+
DynamoFM_Log.warn(
|
|
82
82
|
`using {param} bracets in endpoint definitions will be deprecated... (${set.endPoint})` +
|
|
83
83
|
'use :param instead ({pathparam} --> :pathparam)'
|
|
84
84
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Request, Response } from 'express';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { DynamoFM_Array, DynamoFM_Error, DynamoFM_Log } from '@futdevpro/fsm-dynamo';
|
|
6
6
|
import { DynamoNTS_RouteSecurity } from '../../_enums/route-security.enum';
|
|
7
7
|
import { DynamoNTS_HttpCallType } from '../../_enums/http/http-call-type.enum';
|
|
8
8
|
import { DynamoNTS_globalSettings } from '../../_constants/global-settings.const';
|
|
@@ -91,14 +91,15 @@ export class DynamoNTS_Endpoint_Params {
|
|
|
91
91
|
this.endpoint = set.endpoint;
|
|
92
92
|
|
|
93
93
|
if (!this.endpoint) {
|
|
94
|
-
throw new
|
|
94
|
+
throw new DynamoFM_Error({
|
|
95
95
|
status: 406,
|
|
96
96
|
errorCode: 'NTS-EP0-C00',
|
|
97
97
|
addECToUserMsg: true,
|
|
98
98
|
message: 'trying to create DynamoNTS_EndpointParams without endpoint value',
|
|
99
99
|
userMessage:
|
|
100
100
|
'We encountered an unhandled Server Error, ' +
|
|
101
|
-
'please contact the responsible development team.'
|
|
101
|
+
'please contact the responsible development team.',
|
|
102
|
+
additionalContent: set,
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
|
|
@@ -118,7 +119,7 @@ export class DynamoNTS_Endpoint_Params {
|
|
|
118
119
|
this.logResponseContent =
|
|
119
120
|
set.logResponseContent ?? DynamoNTS_globalSettings.logResponseContent;
|
|
120
121
|
} catch (error) {
|
|
121
|
-
|
|
122
|
+
DynamoFM_Log.error(
|
|
122
123
|
`\nEndpoint params setup failed: name: '${set.name}' ` +
|
|
123
124
|
`(security: ${set.security}) endpoint: ${set.endpoint}` +
|
|
124
125
|
`\nERROR:` +
|
|
@@ -145,9 +146,9 @@ export class DynamoNTS_Endpoint_Params {
|
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
if (this.logRequestsContent && req.body && 0 < Object.keys(req.body).length) {
|
|
148
|
-
|
|
149
|
+
DynamoFM_Log.info(msg + `\nbody:`, req.body);
|
|
149
150
|
} else {
|
|
150
|
-
|
|
151
|
+
DynamoFM_Log.info(msg);
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
|
|
@@ -171,13 +172,13 @@ export class DynamoNTS_Endpoint_Params {
|
|
|
171
172
|
await this.preLog(req, res, issuer);
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
await
|
|
175
|
+
await DynamoFM_Array.asyncForEach(this.preProcessess,
|
|
175
176
|
async (preProcess: (req: Request, res: Response) => Promise<void>): Promise<void> => {
|
|
176
177
|
await preProcess(req, res);
|
|
177
178
|
}
|
|
178
179
|
);
|
|
179
180
|
|
|
180
|
-
await
|
|
181
|
+
await DynamoFM_Array.asyncForEach(this.tasks,
|
|
181
182
|
async (
|
|
182
183
|
task: (req: Request, res: Response, issuer?: string) => Promise<void>
|
|
183
184
|
): Promise<void> => {
|
|
@@ -187,10 +188,10 @@ export class DynamoNTS_Endpoint_Params {
|
|
|
187
188
|
|
|
188
189
|
if (this.logRequest) {
|
|
189
190
|
if (this.logResponseContent) {
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
DynamoFM_Log.success(` <<<===== ${this.name} result sent.`);
|
|
192
|
+
DynamoFM_Log.warn('sorry, the logResponseContent is not implemented yet.');
|
|
192
193
|
} else {
|
|
193
|
-
|
|
194
|
+
DynamoFM_Log.success(` <<<===== ${this.name} result sent.`);
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
197
|
} catch (error) {
|
|
@@ -207,7 +208,7 @@ export class DynamoNTS_Endpoint_Params {
|
|
|
207
208
|
private async error(
|
|
208
209
|
req: Request,
|
|
209
210
|
res: Response,
|
|
210
|
-
error: Error |
|
|
211
|
+
error: Error | DynamoFM_Error,
|
|
211
212
|
issuer: string
|
|
212
213
|
): Promise<void> {
|
|
213
214
|
try {
|
|
@@ -215,20 +216,20 @@ export class DynamoNTS_Endpoint_Params {
|
|
|
215
216
|
|
|
216
217
|
msg += this.getPathParamsLogContent(req);
|
|
217
218
|
|
|
218
|
-
|
|
219
|
-
|
|
219
|
+
DynamoFM_Log.error(msg);
|
|
220
|
+
DynamoFM_Log.error(
|
|
220
221
|
'ERROR:',
|
|
221
|
-
(error as
|
|
222
|
-
(error as
|
|
222
|
+
(error as DynamoFM_Error)?.flag?.includes('DYNAMO') ?
|
|
223
|
+
(error as DynamoFM_Error).getErrorSimplified() :
|
|
223
224
|
error,
|
|
224
225
|
'\n'
|
|
225
226
|
);
|
|
226
227
|
|
|
227
|
-
if ((error as
|
|
228
|
-
if (!(error as
|
|
229
|
-
(error as
|
|
228
|
+
if ((error as DynamoFM_Error)?.flag?.includes('DYNAMO')) {
|
|
229
|
+
if (!(error as DynamoFM_Error).additionalContent) {
|
|
230
|
+
(error as DynamoFM_Error).additionalContent = {};
|
|
230
231
|
}
|
|
231
|
-
(error as
|
|
232
|
+
(error as DynamoFM_Error).additionalContent.endpointInfo = msg;
|
|
232
233
|
}
|
|
233
234
|
|
|
234
235
|
await DynamoNTS_GlobalService.globalErrorHandler?.(
|
|
@@ -237,29 +238,29 @@ export class DynamoNTS_Endpoint_Params {
|
|
|
237
238
|
res,
|
|
238
239
|
issuer
|
|
239
240
|
).catch((err): void => {
|
|
240
|
-
|
|
241
|
-
|
|
241
|
+
DynamoFM_Log.warn('DynamoNTS_GlobalService.globalErrorHandler failed to handle error: ', err);
|
|
242
|
+
DynamoFM_Log.warn('It will proceed as normal.');
|
|
242
243
|
});
|
|
243
244
|
|
|
244
|
-
res.status((error as
|
|
245
|
+
res.status((error as DynamoFM_Error)?.___status ?? 501);
|
|
245
246
|
res.send(error);
|
|
246
247
|
|
|
247
248
|
if (this.logRequest) {
|
|
248
249
|
if (this.logResponseContent) {
|
|
249
|
-
|
|
250
|
-
` <<<===== ${this.name} error sent: ${(error as
|
|
250
|
+
DynamoFM_Log.error(
|
|
251
|
+
` <<<===== ${this.name} error sent: ${(error as DynamoFM_Error)?._message ?? ''}`
|
|
251
252
|
);
|
|
252
|
-
|
|
253
|
+
DynamoFM_Log.error(
|
|
253
254
|
'sorry, the logResponseContent is not implemented yet.'
|
|
254
255
|
);
|
|
255
256
|
} else {
|
|
256
|
-
|
|
257
|
-
` <<<===== ${this.name} error sent: ${(error as
|
|
257
|
+
DynamoFM_Log.error(
|
|
258
|
+
` <<<===== ${this.name} error sent: ${(error as DynamoFM_Error)?._message ?? ''}`
|
|
258
259
|
);
|
|
259
260
|
}
|
|
260
261
|
}
|
|
261
262
|
} catch (error) {
|
|
262
|
-
|
|
263
|
+
DynamoFM_Log.H_error(
|
|
263
264
|
`\n\nDYNAMO MULTILEVEL ERROR:DynamoNTS_EndpointParams: error: ` +
|
|
264
265
|
`(${this.name}, ${this.endpoint})` +
|
|
265
266
|
`\n(DYNAMO MULTILEVEL ERROR means, that the ERRORHANDLING is ALSO FAILED, ` +
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { DynamoFM_Array, DynamoFM_Log } from '@futdevpro/fsm-dynamo';
|
|
3
3
|
import { DynamoNTS_globalSettings } from '../../_constants/global-settings.const';
|
|
4
4
|
import { DynamoNTS_SocketEventKey } from '../../_enums/http/socket-event-type.enum';
|
|
5
5
|
|
|
@@ -86,7 +86,7 @@ export class DynamoNTS_SocketEvent<T>{
|
|
|
86
86
|
this.logEventContent = set.logEventContent !== undefined ?
|
|
87
87
|
set.logEventContent : DynamoNTS_globalSettings.logSocketEventContent;
|
|
88
88
|
} catch (error) {
|
|
89
|
-
|
|
89
|
+
DynamoFM_Log.error(
|
|
90
90
|
`\nSocket Event params setup failed (${this.serviceName}): ${set.eventKey}`,
|
|
91
91
|
error
|
|
92
92
|
);
|
|
@@ -102,15 +102,15 @@ export class DynamoNTS_SocketEvent<T>{
|
|
|
102
102
|
private async getPreLog(content: T, issuer?: string): Promise<void> {
|
|
103
103
|
try {
|
|
104
104
|
if (this.logEventContent && this.eventKey !== DynamoNTS_SocketEventKey.connection) {
|
|
105
|
-
|
|
105
|
+
DynamoFM_Log.log(
|
|
106
106
|
`---> incoming socket(${this.serviceName}) event: ${this.eventKey};
|
|
107
107
|
\ncontent:`, content
|
|
108
108
|
);
|
|
109
109
|
} else {
|
|
110
|
-
|
|
110
|
+
DynamoFM_Log.log(`---> incoming socket(${this.serviceName}) event: ${this.eventKey}...`);
|
|
111
111
|
}
|
|
112
112
|
} catch (error) {
|
|
113
|
-
|
|
113
|
+
DynamoFM_Log.error(`PreLog failed... (socket: ${this.serviceName})`, error);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -124,18 +124,18 @@ export class DynamoNTS_SocketEvent<T>{
|
|
|
124
124
|
await this.getPreLog(content, issuer);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
await
|
|
127
|
+
await DynamoFM_Array.asyncForEach(
|
|
128
128
|
this.preProcessess,
|
|
129
129
|
async (preProcess: DynamoNTS_SocketEventPreprocessTask<any, any>) => {
|
|
130
130
|
content = await preProcess(content);
|
|
131
131
|
}
|
|
132
132
|
);
|
|
133
133
|
|
|
134
|
-
await
|
|
134
|
+
await DynamoFM_Array.asyncForEach(this.tasks, async (task: DynamoNTS_SocketEventTask<T>) => {
|
|
135
135
|
await task(content, issuer);
|
|
136
136
|
});
|
|
137
137
|
} catch (error) {
|
|
138
|
-
|
|
138
|
+
DynamoFM_Log.error(
|
|
139
139
|
`Socket Event tasks failed to execute on ${this.serviceName}.... (${this.eventKey})`,
|
|
140
140
|
error,
|
|
141
141
|
'content:',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
DynamoFM_AnyError, DynamoFM_Error, DynamoFM_Error_Settings, DynamoFM_Log
|
|
4
4
|
} from '@futdevpro/fsm-dynamo';
|
|
5
5
|
import * as SocketIO from 'socket.io';
|
|
6
6
|
|
|
@@ -43,7 +43,7 @@ export class DynamoNTS_SocketPresence {
|
|
|
43
43
|
}
|
|
44
44
|
) {
|
|
45
45
|
if (!set?.issuerId) {
|
|
46
|
-
throw new
|
|
46
|
+
throw new DynamoFM_Error({
|
|
47
47
|
...this._getDefaultErrorSettings(
|
|
48
48
|
'constructor',
|
|
49
49
|
new Error(
|
|
@@ -72,7 +72,7 @@ export class DynamoNTS_SocketPresence {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
if (!set?.sockets?.length) {
|
|
75
|
-
throw new
|
|
75
|
+
throw new DynamoFM_Error({
|
|
76
76
|
...this._getDefaultErrorSettings(
|
|
77
77
|
'constructor',
|
|
78
78
|
new Error(
|
|
@@ -101,13 +101,13 @@ export class DynamoNTS_SocketPresence {
|
|
|
101
101
|
|
|
102
102
|
this.sockets.forEach((socket: SocketIO.Socket, index: number) => {
|
|
103
103
|
if (!socket.connected) {
|
|
104
|
-
|
|
104
|
+
DynamoFM_Log.warn(
|
|
105
105
|
`Emitting event '${event}' on socket(${this.serviceName})-(${index}) failed!` +
|
|
106
106
|
`\nERROR: socket[${socket.id}] is not connected! (it will be removed...)`
|
|
107
107
|
);
|
|
108
108
|
|
|
109
109
|
/* errors.push(
|
|
110
|
-
new
|
|
110
|
+
new DynamoFM_Error({
|
|
111
111
|
status: 500,
|
|
112
112
|
errorCode: 'NTS-SPC-EE1',
|
|
113
113
|
addECToUserMsg: true,
|
|
@@ -137,7 +137,7 @@ export class DynamoNTS_SocketPresence {
|
|
|
137
137
|
|
|
138
138
|
this.sockets.forEach((socket: SocketIO.Socket, index: number): void => {
|
|
139
139
|
const success: boolean = socket.emit(event, content, (error): void => {
|
|
140
|
-
|
|
140
|
+
DynamoFM_Log.error(
|
|
141
141
|
`Emitting event '${event}' on socket(${this.serviceName})-(${index}) failed!(0)` +
|
|
142
142
|
`\nerror:`, error
|
|
143
143
|
);
|
|
@@ -145,14 +145,14 @@ export class DynamoNTS_SocketPresence {
|
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
if (!success) {
|
|
148
|
-
|
|
148
|
+
DynamoFM_Log.error(
|
|
149
149
|
`Emitting event '${event}' on socket(${this.serviceName})-(${index}) failed!(1)`
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
if (0 < errors.length) {
|
|
155
|
-
throw new
|
|
155
|
+
throw new DynamoFM_Error({
|
|
156
156
|
...this._getDefaultErrorSettings(
|
|
157
157
|
'emitEvent',
|
|
158
158
|
new Error(
|
|
@@ -171,7 +171,7 @@ export class DynamoNTS_SocketPresence {
|
|
|
171
171
|
});
|
|
172
172
|
|
|
173
173
|
} else if (this.sockets.length === 0) {
|
|
174
|
-
throw new
|
|
174
|
+
throw new DynamoFM_Error({
|
|
175
175
|
...this._getDefaultErrorSettings(
|
|
176
176
|
'emitEvent',
|
|
177
177
|
new Error(
|
|
@@ -189,15 +189,15 @@ export class DynamoNTS_SocketPresence {
|
|
|
189
189
|
|
|
190
190
|
private _getDefaultErrorSettings(
|
|
191
191
|
fnName: string,
|
|
192
|
-
error:
|
|
192
|
+
error: DynamoFM_AnyError,
|
|
193
193
|
issuer: string
|
|
194
|
-
):
|
|
194
|
+
): DynamoFM_Error_Settings {
|
|
195
195
|
return {
|
|
196
|
-
status: (error as
|
|
196
|
+
status: (error as DynamoFM_Error)?.___status ?? 406,
|
|
197
197
|
message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS; ${this.serviceName})`,
|
|
198
|
-
userMessage: (error as
|
|
198
|
+
userMessage: (error as DynamoFM_Error)?.__userMessage ?? this.defaultErrorUserMsg,
|
|
199
199
|
issuerService: this.serviceName + ` (${this?.constructor?.name}-DynamoNTS_SocketPresence)`,
|
|
200
|
-
addECToUserMsg: !(error as
|
|
200
|
+
addECToUserMsg: !(error as DynamoFM_Error)?.__userMessage,
|
|
201
201
|
issuer: issuer,
|
|
202
202
|
error: error,
|
|
203
203
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Request, Response } from 'express';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { DynamoFM_DataModel_Params } from '@futdevpro/fsm-dynamo';
|
|
8
8
|
|
|
9
9
|
import { DynamoNTS_Service_Collection } from '../../_services/core/service-collection.service';
|
|
10
10
|
import { DynamoNTS_EmailService } from '../../_services/core/email.service';
|
|
@@ -23,9 +23,9 @@ export interface DynamoNTS_GlobalService_Settings {
|
|
|
23
23
|
emailServiceCollection?: DynamoNTS_Service_Collection<DynamoNTS_EmailService>,
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* you can setup data tables by passing a
|
|
26
|
+
* you can setup data tables by passing a DynamoFM_DataModel_Params list at this point
|
|
27
27
|
*/
|
|
28
|
-
dbModels?:
|
|
28
|
+
dbModels?: DynamoFM_DataModel_Params[],
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* you can setup other services by passing a DynamoNTS_SingletonService list at this point
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { DynamoFM_customDataModule_settings } from '@futdevpro/fsm-dynamo';
|
|
5
5
|
|
|
6
6
|
import { DynamoNTS_HttpCallType } from '../../_enums/http/http-call-type.enum';
|
|
7
7
|
import { DynamoNTS_Controller } from '../../_services/route/controller.service';
|
|
8
|
-
import {
|
|
8
|
+
import { DynamoFM_CustomData_DataService } from './custom-data.data-service';
|
|
9
9
|
import {
|
|
10
10
|
DynamoNTS_Endpoint_Params
|
|
11
11
|
} from '../../_models/control-models/endpoint-params.control-model';
|
|
@@ -22,10 +22,10 @@ export class DynamoNTS_CustomData_Controller extends DynamoNTS_Controller {
|
|
|
22
22
|
new DynamoNTS_Endpoint_Params({
|
|
23
23
|
name: 'getCustomData',
|
|
24
24
|
type: DynamoNTS_HttpCallType.get,
|
|
25
|
-
endpoint:
|
|
25
|
+
endpoint: DynamoFM_customDataModule_settings.endPoints.getCustomData,
|
|
26
26
|
tasks: [
|
|
27
27
|
async (req: Request, res: Response): Promise<void> => {
|
|
28
|
-
const customDataService = new
|
|
28
|
+
const customDataService = new DynamoFM_CustomData_DataService({
|
|
29
29
|
_id: req.params.customId,
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -44,10 +44,10 @@ export class DynamoNTS_CustomData_Controller extends DynamoNTS_Controller {
|
|
|
44
44
|
new DynamoNTS_Endpoint_Params({
|
|
45
45
|
name: 'modifyCustomData',
|
|
46
46
|
type: DynamoNTS_HttpCallType.post,
|
|
47
|
-
endpoint:
|
|
47
|
+
endpoint: DynamoFM_customDataModule_settings.endPoints.modifyCustomData,
|
|
48
48
|
tasks: [
|
|
49
49
|
async (req: Request, res: Response, issuer: string): Promise<void> => {
|
|
50
|
-
const customDataService = new
|
|
50
|
+
const customDataService = new DynamoFM_CustomData_DataService(req.body, issuer);
|
|
51
51
|
|
|
52
52
|
await customDataService.saveData();
|
|
53
53
|
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
DynamoFM_customDataModel_params, DynamoFM_CustomData
|
|
6
6
|
} from '@futdevpro/fsm-dynamo/custom-data-module';
|
|
7
7
|
import { DynamoNTS_DataService } from '../../_services/base/data.service';
|
|
8
8
|
|
|
9
|
-
export class
|
|
9
|
+
export class DynamoFM_CustomData_DataService extends DynamoNTS_DataService<DynamoFM_CustomData> {
|
|
10
10
|
|
|
11
11
|
constructor(
|
|
12
|
-
customData?:
|
|
12
|
+
customData?: DynamoFM_CustomData,
|
|
13
13
|
issuer?: string
|
|
14
14
|
) {
|
|
15
15
|
super(
|
|
16
|
-
new
|
|
17
|
-
|
|
16
|
+
new DynamoFM_CustomData(customData),
|
|
17
|
+
DynamoFM_customDataModel_params,
|
|
18
18
|
issuer
|
|
19
19
|
);
|
|
20
20
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { DynamoFM_customDataModule_settings } from '@futdevpro/fsm-dynamo';
|
|
3
3
|
import { DynamoNTS_RouteSecurity } from '../../_enums/route-security.enum';
|
|
4
4
|
import {
|
|
5
5
|
DynamoNTS_RoutingModule_Settings
|
|
@@ -11,7 +11,7 @@ export function DynamoNTS_getCustomDataRoutingModule(
|
|
|
11
11
|
securityOverride?: DynamoNTS_RouteSecurity
|
|
12
12
|
): DynamoNTS_RoutingModule {
|
|
13
13
|
const set: DynamoNTS_RoutingModule_Settings = {
|
|
14
|
-
route:
|
|
14
|
+
route: DynamoFM_customDataModule_settings.mainRoute,
|
|
15
15
|
controllers: [ DynamoNTS_CustomData_Controller.getInstance() ],
|
|
16
16
|
};
|
|
17
17
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { DynamoFM_testModule_settings } from '@futdevpro/fsm-dynamo/test-module';
|
|
3
3
|
import { DynamoNTS_RouteSecurity } from '../../_enums/route-security.enum';
|
|
4
4
|
import {
|
|
5
5
|
DynamoNTS_RoutingModule_Settings
|
|
@@ -11,7 +11,7 @@ export function DynamoNTS_getTestRoutingModule(
|
|
|
11
11
|
securityOverride?: DynamoNTS_RouteSecurity
|
|
12
12
|
): DynamoNTS_RoutingModule {
|
|
13
13
|
const set: DynamoNTS_RoutingModule_Settings = {
|
|
14
|
-
route:
|
|
14
|
+
route: DynamoFM_testModule_settings.mainRoute,
|
|
15
15
|
controllers: [ DynamoNTS_Test_Controller.getInstance() ],
|
|
16
16
|
};
|
|
17
17
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { DynamoFM_testModule_settings } from '@futdevpro/fsm-dynamo/test-module';
|
|
5
5
|
|
|
6
6
|
import { DynamoNTS_HttpCallType } from '../../_enums/http/http-call-type.enum';
|
|
7
7
|
import { DynamoNTS_Controller } from '../../_services/route/controller.service';
|
|
@@ -22,7 +22,7 @@ export class DynamoNTS_Test_Controller extends DynamoNTS_Controller {
|
|
|
22
22
|
new DynamoNTS_Endpoint_Params({
|
|
23
23
|
name: 'testGet',
|
|
24
24
|
type: DynamoNTS_HttpCallType.get,
|
|
25
|
-
endpoint:
|
|
25
|
+
endpoint: DynamoFM_testModule_settings.endPoints.testGet,
|
|
26
26
|
tasks: [
|
|
27
27
|
async (req: Request, res: Response): Promise<void> => {
|
|
28
28
|
res.send({
|
|
@@ -37,7 +37,7 @@ export class DynamoNTS_Test_Controller extends DynamoNTS_Controller {
|
|
|
37
37
|
new DynamoNTS_Endpoint_Params({
|
|
38
38
|
name: 'testPost',
|
|
39
39
|
type: DynamoNTS_HttpCallType.post,
|
|
40
|
-
endpoint:
|
|
40
|
+
endpoint: DynamoFM_testModule_settings.endPoints.testPost,
|
|
41
41
|
tasks: [
|
|
42
42
|
async (req: Request, res: Response): Promise<void> => {
|
|
43
43
|
res.send({
|
|
@@ -52,7 +52,7 @@ export class DynamoNTS_Test_Controller extends DynamoNTS_Controller {
|
|
|
52
52
|
new DynamoNTS_Endpoint_Params({
|
|
53
53
|
name: 'testPut',
|
|
54
54
|
type: DynamoNTS_HttpCallType.put,
|
|
55
|
-
endpoint:
|
|
55
|
+
endpoint: DynamoFM_testModule_settings.endPoints.testPut,
|
|
56
56
|
tasks: [
|
|
57
57
|
async (req: Request, res: Response): Promise<void> => {
|
|
58
58
|
res.send({
|
|
@@ -67,7 +67,7 @@ export class DynamoNTS_Test_Controller extends DynamoNTS_Controller {
|
|
|
67
67
|
new DynamoNTS_Endpoint_Params({
|
|
68
68
|
name: 'testPatch',
|
|
69
69
|
type: DynamoNTS_HttpCallType.patch,
|
|
70
|
-
endpoint:
|
|
70
|
+
endpoint: DynamoFM_testModule_settings.endPoints.testPatch,
|
|
71
71
|
tasks: [
|
|
72
72
|
async (req: Request, res: Response): Promise<void> => {
|
|
73
73
|
res.send({
|
|
@@ -82,7 +82,7 @@ export class DynamoNTS_Test_Controller extends DynamoNTS_Controller {
|
|
|
82
82
|
new DynamoNTS_Endpoint_Params({
|
|
83
83
|
name: 'testDelete',
|
|
84
84
|
type: DynamoNTS_HttpCallType.delete,
|
|
85
|
-
endpoint:
|
|
85
|
+
endpoint: DynamoFM_testModule_settings.endPoints.testDelete,
|
|
86
86
|
tasks: [
|
|
87
87
|
async (req: Request, res: Response): Promise<void> => {
|
|
88
88
|
res.send({
|
|
@@ -97,7 +97,7 @@ export class DynamoNTS_Test_Controller extends DynamoNTS_Controller {
|
|
|
97
97
|
new DynamoNTS_Endpoint_Params({
|
|
98
98
|
name: 'getServerStatus',
|
|
99
99
|
type: DynamoNTS_HttpCallType.get,
|
|
100
|
-
endpoint:
|
|
100
|
+
endpoint: DynamoFM_testModule_settings.endPoints.getServerStatus,
|
|
101
101
|
tasks: [
|
|
102
102
|
async (req: Request, res: Response): Promise<void> => {
|
|
103
103
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { DynamoFM_usageModule_settings } from '@futdevpro/fsm-dynamo/usage-module';
|
|
3
3
|
import { DynamoNTS_RouteSecurity } from '../../_enums/route-security.enum';
|
|
4
4
|
import {
|
|
5
5
|
DynamoNTS_RoutingModule_Settings
|
|
@@ -11,7 +11,7 @@ export function DynamoNTS_getUsageRoutingModule(
|
|
|
11
11
|
securityOverride?: DynamoNTS_RouteSecurity
|
|
12
12
|
): DynamoNTS_RoutingModule {
|
|
13
13
|
const set: DynamoNTS_RoutingModule_Settings = {
|
|
14
|
-
route:
|
|
14
|
+
route: DynamoFM_usageModule_settings.mainRoute,
|
|
15
15
|
controllers: [ DynamoNTS_Usage_Controller.getInstance() ],
|
|
16
16
|
};
|
|
17
17
|
|