@futdevpro/nts-dynamo 1.5.62 → 1.5.65
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/lib/_models/dynamo-nts-endpoint-params.js +8 -8
- package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -1
- package/lib/_models/dynamo-nts-socket-event-params.js +1 -1
- package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
- package/lib/_models/dynamo-nts-socket-service-params.js +1 -1
- package/lib/_models/dynamo-nts-socket-service-params.js.map +1 -1
- package/lib/_modules/custom-data/custom-data.controller.d.ts +6 -0
- package/lib/_modules/custom-data/custom-data.controller.d.ts.map +1 -0
- package/lib/_modules/custom-data/custom-data.controller.js +56 -0
- package/lib/_modules/custom-data/custom-data.controller.js.map +1 -0
- package/lib/_modules/custom-data/custom-data.service.d.ts +6 -0
- package/lib/_modules/custom-data/custom-data.service.d.ts.map +1 -0
- package/lib/_modules/custom-data/custom-data.service.js +12 -0
- package/lib/_modules/custom-data/custom-data.service.js.map +1 -0
- package/lib/_modules/custom-data/get-custom-data-routing-module.d.ts +4 -0
- package/lib/_modules/custom-data/get-custom-data-routing-module.d.ts.map +1 -0
- package/lib/_modules/custom-data/get-custom-data-routing-module.js +18 -0
- package/lib/_modules/custom-data/get-custom-data-routing-module.js.map +1 -0
- package/lib/_modules/custom-data/index.d.ts +5 -0
- package/lib/_modules/custom-data/index.d.ts.map +1 -0
- package/lib/_modules/custom-data/index.js +9 -0
- package/lib/_modules/custom-data/index.js.map +1 -0
- package/lib/_modules/test/get-test-routing-module.js +1 -1
- package/lib/_modules/test/index.d.ts +1 -2
- package/lib/_modules/test/index.d.ts.map +1 -1
- package/lib/_modules/test/index.js +1 -2
- package/lib/_modules/test/index.js.map +1 -1
- package/lib/_modules/test/test.controller.d.ts +6 -0
- package/lib/_modules/test/test.controller.d.ts.map +1 -0
- package/lib/_modules/test/test.controller.js +102 -0
- package/lib/_modules/test/test.controller.js.map +1 -0
- package/lib/_services/dynamo-nts-api.service.js +8 -8
- package/lib/_services/dynamo-nts-api.service.js.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.js +3 -3
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
- package/lib/_services/dynamo-nts-app.js +12 -12
- package/lib/_services/dynamo-nts-app.js.map +1 -1
- package/lib/_services/dynamo-nts-auth.service.d.ts +4 -4
- package/lib/_services/dynamo-nts-controller.service.js +1 -1
- package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
- package/lib/_services/dynamo-nts-data.service.d.ts +3 -3
- package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-data.service.js +6 -6
- package/lib/_services/dynamo-nts-data.service.js.map +1 -1
- package/lib/_services/dynamo-nts-db.service.d.ts +3 -3
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-db.service.js +120 -119
- package/lib/_services/dynamo-nts-db.service.js.map +1 -1
- package/lib/_services/dynamo-nts-email.service.js +8 -8
- package/lib/_services/dynamo-nts-email.service.js.map +1 -1
- package/lib/_services/dynamo-nts-global.service.d.ts +4 -4
- package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-global.service.js +2 -2
- package/lib/_services/dynamo-nts-global.service.js.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.js +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.js +1 -1
- package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -2
- package/src/_models/dynamo-nts-endpoint-params.ts +8 -8
- package/src/_models/dynamo-nts-socket-event-params.ts +1 -1
- package/src/_models/dynamo-nts-socket-service-params.ts +1 -1
- package/src/_modules/custom-data/custom-data.controller.ts +62 -0
- package/src/_modules/{test → custom-data}/custom-data.service.ts +1 -1
- package/src/_modules/custom-data/get-custom-data-routing-module.ts +17 -0
- package/src/_modules/custom-data/index.ts +6 -0
- package/src/_modules/test/get-test-routing-module.ts +1 -1
- package/src/_modules/test/index.ts +1 -2
- package/src/_modules/test/{test-controller.ts → test.controller.ts} +4 -33
- package/src/_services/dynamo-nts-api.service.ts +8 -8
- package/src/_services/dynamo-nts-app-extended.ts +3 -3
- package/src/_services/dynamo-nts-app.ts +12 -12
- package/src/_services/dynamo-nts-auth.service.ts +4 -4
- package/src/_services/dynamo-nts-controller.service.ts +1 -1
- package/src/_services/dynamo-nts-data.service.ts +10 -10
- package/src/_services/dynamo-nts-db.service.ts +37 -36
- package/src/_services/dynamo-nts-email.service.ts +8 -8
- package/src/_services/dynamo-nts-global.service.ts +7 -7
- package/src/_services/dynamo-nts-routing-module.service.ts +1 -1
- package/src/_services/dynamo-nts-socket.service.ts +1 -1
|
@@ -31,7 +31,7 @@ export class DynamoNTS_SocketServiceParams {
|
|
|
31
31
|
if (set.getIdFromSubscrioption) {
|
|
32
32
|
this.getIdFromSubscrioption = set.getIdFromSubscrioption;
|
|
33
33
|
if (set.groupActiveSocketsBy) {
|
|
34
|
-
Dynamo_Log.
|
|
34
|
+
Dynamo_Log.error(
|
|
35
35
|
`setting groupActiveSocketsBy on DynamoNTS_SocketService (${this.name}) won't take effect, ` +
|
|
36
36
|
`since getIdFromSubscrioption is also setted, so it will be used instead`)
|
|
37
37
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { customDataModuleSettings } from '@futdevpro/fsm-dynamo';
|
|
4
|
+
import { Request, Response } from 'express';
|
|
5
|
+
import { HttpCallType } from '../../_enums/http/http-call-type.enum';
|
|
6
|
+
import { DynamoNTS_EndpointParams } from '../../_models/dynamo-nts-endpoint-params';
|
|
7
|
+
import { DynamoNTS_Controller } from '../../_services/dynamo-nts-controller.service';
|
|
8
|
+
import { Dynamo_CustomDataService } from '../custom-data/custom-data.service';
|
|
9
|
+
|
|
10
|
+
export class CustomDataController extends DynamoNTS_Controller {
|
|
11
|
+
|
|
12
|
+
static getInstance(): CustomDataController {
|
|
13
|
+
return CustomDataController.getSingletonInstance();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
setupEndpoints(): void {
|
|
17
|
+
this.endpoints = [
|
|
18
|
+
// CUSTOM DATA
|
|
19
|
+
new DynamoNTS_EndpointParams({
|
|
20
|
+
name: 'getCustomData',
|
|
21
|
+
type: HttpCallType.get,
|
|
22
|
+
endpoint: customDataModuleSettings.endPoints.getCustomData,
|
|
23
|
+
tasks: [
|
|
24
|
+
async (req: Request, res: Response) => {
|
|
25
|
+
const customDataService = new Dynamo_CustomDataService({ _id: req.params.customId });
|
|
26
|
+
|
|
27
|
+
await customDataService.getDataById();
|
|
28
|
+
|
|
29
|
+
res.send({
|
|
30
|
+
url: req.url,
|
|
31
|
+
result: 'get custom call was successful!',
|
|
32
|
+
response: customDataService.data,
|
|
33
|
+
request: `.../custom/get/${req.params.customId}`
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}),
|
|
38
|
+
|
|
39
|
+
new DynamoNTS_EndpointParams({
|
|
40
|
+
name: 'modifyCustomData',
|
|
41
|
+
type: HttpCallType.post,
|
|
42
|
+
endpoint: customDataModuleSettings.endPoints.modifyCustomData,
|
|
43
|
+
tasks: [
|
|
44
|
+
async (req: Request, res: Response, issuer: string) => {
|
|
45
|
+
const customDataService = new Dynamo_CustomDataService(req.body, issuer);
|
|
46
|
+
|
|
47
|
+
await customDataService.saveData();
|
|
48
|
+
|
|
49
|
+
res.send({
|
|
50
|
+
url: req.url,
|
|
51
|
+
result: 'post custom call was successful!',
|
|
52
|
+
response: customDataService.data,
|
|
53
|
+
warning: 'keep in mind that this is a playground DB, and it will be cleared out from time to time',
|
|
54
|
+
request: req.body
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}),
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { customDataModelParams, Dynamo_CustomData } from '@futdevpro/fsm-dynamo/custom-data-module';
|
|
5
5
|
import { DynamoNTS_DataService } from '../../_services/dynamo-nts-data.service';
|
|
6
6
|
|
|
7
7
|
export class Dynamo_CustomDataService extends DynamoNTS_DataService<Dynamo_CustomData> {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { customDataModuleSettings } from '@futdevpro/fsm-dynamo';
|
|
3
|
+
import { DynamoNTS_RouteSecurity } from '../../_enums/dynamo-nts-route-security.enum';
|
|
4
|
+
import { DynamoNTS_RoutingModuleSettings } from '../../_models/dynamo-nts-routing-module-settings';
|
|
5
|
+
import { DynamoNTS_RoutingModule } from '../../_services/dynamo-nts-routing-module.service';
|
|
6
|
+
import { CustomDataController } from './custom-data.controller';
|
|
7
|
+
|
|
8
|
+
export function getCustomDataRoutingModule(securityOverride?: DynamoNTS_RouteSecurity): DynamoNTS_RoutingModule {
|
|
9
|
+
const set: DynamoNTS_RoutingModuleSettings = {
|
|
10
|
+
route: customDataModuleSettings.mainRoute,
|
|
11
|
+
controllers: [ CustomDataController.getInstance() ]
|
|
12
|
+
}
|
|
13
|
+
if (securityOverride) {
|
|
14
|
+
set.securityOverride = securityOverride;
|
|
15
|
+
}
|
|
16
|
+
return new DynamoNTS_RoutingModule(set);
|
|
17
|
+
}
|
|
@@ -3,7 +3,7 @@ import { testModuleSettings } from '@futdevpro/fsm-dynamo/test-module';
|
|
|
3
3
|
import { DynamoNTS_RouteSecurity } from '../../_enums/dynamo-nts-route-security.enum';
|
|
4
4
|
import { DynamoNTS_RoutingModuleSettings } from '../../_models/dynamo-nts-routing-module-settings';
|
|
5
5
|
import { DynamoNTS_RoutingModule } from '../../_services/dynamo-nts-routing-module.service';
|
|
6
|
-
import { TestController } from './test
|
|
6
|
+
import { TestController } from './test.controller';
|
|
7
7
|
|
|
8
8
|
export function getTestRoutingModule(securityOverride?: DynamoNTS_RouteSecurity): DynamoNTS_RoutingModule {
|
|
9
9
|
const set: DynamoNTS_RoutingModuleSettings = {
|
|
@@ -4,7 +4,6 @@ import { testModuleSettings } from '@futdevpro/fsm-dynamo/test-module';
|
|
|
4
4
|
import { HttpCallType } from '../../_enums/http/http-call-type.enum';
|
|
5
5
|
import { DynamoNTS_EndpointParams } from '../../_models/dynamo-nts-endpoint-params';
|
|
6
6
|
import { DynamoNTS_Controller } from '../../_services/dynamo-nts-controller.service';
|
|
7
|
-
import { Dynamo_CustomDataService } from './custom-data.service';
|
|
8
7
|
|
|
9
8
|
export class TestController extends DynamoNTS_Controller {
|
|
10
9
|
|
|
@@ -90,43 +89,15 @@ export class TestController extends DynamoNTS_Controller {
|
|
|
90
89
|
]
|
|
91
90
|
}),
|
|
92
91
|
|
|
93
|
-
// CUSTOM DATA
|
|
94
92
|
new DynamoNTS_EndpointParams({
|
|
95
|
-
name: '
|
|
93
|
+
name: 'getServerStatus',
|
|
96
94
|
type: HttpCallType.get,
|
|
97
|
-
endpoint: testModuleSettings.endPoints.
|
|
95
|
+
endpoint: testModuleSettings.endPoints.getServerStatus,
|
|
98
96
|
tasks: [
|
|
99
97
|
async (req: Request, res: Response) => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
await customDataService.getDataById();
|
|
103
|
-
|
|
104
|
-
res.send({
|
|
105
|
-
url: req.url,
|
|
106
|
-
result: 'get custom call was successful!',
|
|
107
|
-
response: customDataService.data,
|
|
108
|
-
request: `.../custom/get/${req.params.customId}`
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
}),
|
|
113
|
-
|
|
114
|
-
new DynamoNTS_EndpointParams({
|
|
115
|
-
name: 'modifyCustomData',
|
|
116
|
-
type: HttpCallType.post,
|
|
117
|
-
endpoint: testModuleSettings.endPoints.modifyCustomData,
|
|
118
|
-
tasks: [
|
|
119
|
-
async (req: Request, res: Response, issuer: string) => {
|
|
120
|
-
const customDataService = new Dynamo_CustomDataService(req.body, issuer);
|
|
121
|
-
|
|
122
|
-
await customDataService.saveData();
|
|
123
|
-
|
|
98
|
+
|
|
124
99
|
res.send({
|
|
125
|
-
|
|
126
|
-
result: 'post custom call was successful!',
|
|
127
|
-
response: customDataService.data,
|
|
128
|
-
warning: 'keep in mind that this is a playground DB, and it will be cleared out from time to time',
|
|
129
|
-
request: req.body
|
|
100
|
+
status: 'ready'
|
|
130
101
|
});
|
|
131
102
|
}
|
|
132
103
|
]
|
|
@@ -53,7 +53,7 @@ export class DynamoNTS_ApiService {
|
|
|
53
53
|
if (callParams.httpOptions.headers[headerKey]) {
|
|
54
54
|
privateAxiosInstance.defaults.headers.common[headerKey] = callParams.httpOptions.headers[headerKey];
|
|
55
55
|
} else {
|
|
56
|
-
Dynamo_Log.
|
|
56
|
+
Dynamo_Log.error('DYNAMOBE ERROR: \n missing header:', headerKey, '\n\n', new Error());
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -70,11 +70,11 @@ export class DynamoNTS_ApiService {
|
|
|
70
70
|
url = url.replace(`:${pathParamKey}`, inputParams.pathParams[pathParamKey]);
|
|
71
71
|
break;
|
|
72
72
|
default:
|
|
73
|
-
Dynamo_Log.
|
|
73
|
+
Dynamo_Log.error(`DYNAMOBE ERROR: \n wrong path param type: (${pathParamKey}): ${paramType} \n${inputParams.pathParams[pathParamKey]}\nMUST BE string or number\n\n`, new Error());
|
|
74
74
|
break;
|
|
75
75
|
}
|
|
76
76
|
} else {
|
|
77
|
-
Dynamo_Log.
|
|
77
|
+
Dynamo_Log.error('DYNAMOBE ERROR: \n missing pathParam:', pathParamKey, '\n\n', new Error());
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -143,7 +143,7 @@ export class DynamoNTS_ApiService {
|
|
|
143
143
|
});
|
|
144
144
|
break;
|
|
145
145
|
default:
|
|
146
|
-
Dynamo_Log.
|
|
146
|
+
Dynamo_Log.error('DYNAMOBE ERROR: \n wrong api call type', '\n\n', new Error());
|
|
147
147
|
break;
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -153,7 +153,7 @@ export class DynamoNTS_ApiService {
|
|
|
153
153
|
return a as T;
|
|
154
154
|
}
|
|
155
155
|
} catch (error) {
|
|
156
|
-
Dynamo_Log.
|
|
156
|
+
Dynamo_Log.error(`\nAPI ERROR: ${callParams?.name} failed...` +
|
|
157
157
|
`\n${callParams?.baseUrl}${callParams?.endPoint}`);
|
|
158
158
|
|
|
159
159
|
if (callParams?.httpOptions?.responseType === HttpResponseType.text) {
|
|
@@ -161,7 +161,7 @@ export class DynamoNTS_ApiService {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
if (error?.response?.data?.flag === 'DYNAMO ERROR OBJECT') {
|
|
164
|
-
Dynamo_Log.
|
|
164
|
+
Dynamo_Log.error(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
|
|
165
165
|
|
|
166
166
|
throw new Dynamo_Error({
|
|
167
167
|
errorCode: 'NTS-API-002',
|
|
@@ -171,7 +171,7 @@ export class DynamoNTS_ApiService {
|
|
|
171
171
|
error: error.response.data
|
|
172
172
|
});
|
|
173
173
|
} else if (error.code === 'ENOTFOUND') {
|
|
174
|
-
Dynamo_Log.
|
|
174
|
+
Dynamo_Log.error(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
|
|
175
175
|
|
|
176
176
|
throw new Dynamo_Error({
|
|
177
177
|
status: 404,
|
|
@@ -191,7 +191,7 @@ export class DynamoNTS_ApiService {
|
|
|
191
191
|
error
|
|
192
192
|
});
|
|
193
193
|
} else {
|
|
194
|
-
Dynamo_Log.
|
|
194
|
+
Dynamo_Log.error(`\n${callParams.name} was UNSUCCESSFUL`, error, '\n\n', new Error());
|
|
195
195
|
|
|
196
196
|
throw error;
|
|
197
197
|
}
|
|
@@ -134,13 +134,13 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
134
134
|
|
|
135
135
|
if (this.debugLog) console.log(`\nAll sockets setted up.... sockets using security: ${this.socketSecurity}`);
|
|
136
136
|
} else {
|
|
137
|
-
Dynamo_Log.
|
|
137
|
+
Dynamo_Log.warn(
|
|
138
138
|
'\nNo socketServices setted up while using Extended Application.',
|
|
139
139
|
'\nYou should use DynamoNTS_App if you don`t need socket services.\n'
|
|
140
140
|
);
|
|
141
141
|
}
|
|
142
142
|
} catch (error) {
|
|
143
|
-
Dynamo_Log.
|
|
143
|
+
Dynamo_Log.error('\nExtended Application start failed.\n', error, '\n');
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -188,7 +188,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
188
188
|
errorMsg += `\n ${service.name} (port: ${service.port})`;
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
|
-
Dynamo_Log.
|
|
191
|
+
Dynamo_Log.error(errorMsg);
|
|
192
192
|
|
|
193
193
|
let error = new Error('Secure routes cannot be established!');
|
|
194
194
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -204,7 +204,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
204
204
|
if (this.debugLog) console.log(`\nRoutes mounted.... server using security: ${this.security}`);
|
|
205
205
|
}
|
|
206
206
|
} catch (error) {
|
|
207
|
-
Dynamo_Log.
|
|
207
|
+
Dynamo_Log.error('\nApplication start failed.\n', error);
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -214,10 +214,10 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
214
214
|
private startDB(): void {
|
|
215
215
|
this.mongoose.connection
|
|
216
216
|
.on('error', (error) => {
|
|
217
|
-
Dynamo_Log.
|
|
217
|
+
Dynamo_Log.error('\nUnable to connect to MongoDB server, ERROR: ', error);
|
|
218
218
|
})
|
|
219
219
|
.once('open', () => {
|
|
220
|
-
Dynamo_Log.
|
|
220
|
+
Dynamo_Log.success('\nConnected to MongoDB\n');
|
|
221
221
|
});
|
|
222
222
|
|
|
223
223
|
this.mongoose.connect(
|
|
@@ -251,7 +251,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
251
251
|
});
|
|
252
252
|
}
|
|
253
253
|
});
|
|
254
|
-
Dynamo_Log.
|
|
254
|
+
Dynamo_Log.error(errorMsg);
|
|
255
255
|
|
|
256
256
|
let error = new Error('Open routes cannot be established!');
|
|
257
257
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -288,7 +288,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
290
|
});
|
|
291
|
-
Dynamo_Log.
|
|
291
|
+
Dynamo_Log.error(errorMsg);
|
|
292
292
|
|
|
293
293
|
let error = new Error('Secure routes cannot be established!');
|
|
294
294
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -334,30 +334,30 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
334
334
|
if (this.security !== DynamoNTS_RouteSecurity.open) {
|
|
335
335
|
this.httpsServer
|
|
336
336
|
.listen(this.httpsPort, 'localhost', 0, () => {
|
|
337
|
-
Dynamo_Log.
|
|
337
|
+
Dynamo_Log.success(`\nHTTPS (secure) server is listening on port ${this.httpsPort}\n`);
|
|
338
338
|
})
|
|
339
339
|
.on('error', (error) => {
|
|
340
|
-
Dynamo_Log.
|
|
340
|
+
Dynamo_Log.error(`\nHTTPS (secure) server ERROR`, error);
|
|
341
341
|
})
|
|
342
342
|
.on('uncaughtException', (ex) => {
|
|
343
|
-
Dynamo_Log.
|
|
343
|
+
Dynamo_Log.warn(`\nHTTPS (secure) server uncaughtException`, ex);
|
|
344
344
|
});
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
if (this.security !== DynamoNTS_RouteSecurity.secure) {
|
|
348
348
|
this.openExpress
|
|
349
349
|
.listen(this.httpPort, () => {
|
|
350
|
-
Dynamo_Log.
|
|
350
|
+
Dynamo_Log.success(`\nHTTP (-open-) server is listening on port ${this.httpPort}\n`);
|
|
351
351
|
})
|
|
352
352
|
.on('error', (error) => {
|
|
353
|
-
Dynamo_Log.
|
|
353
|
+
Dynamo_Log.error(`\nHTTP (-open-) server ERROR`, error);
|
|
354
354
|
})
|
|
355
355
|
.on('uncaughtException', (ex) => {
|
|
356
|
-
Dynamo_Log.
|
|
356
|
+
Dynamo_Log.warn(`\nHTTP (-open-) server uncaughtException`, ex);
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
359
|
} catch (error) {
|
|
360
|
-
Dynamo_Log.
|
|
360
|
+
Dynamo_Log.error(`startExpresses failed...`, error);
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
|
|
@@ -67,7 +67,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
67
67
|
* let token = AuthService.getTokenFromRequest(req);
|
|
68
68
|
* token = await AuthService.verifyToken(token);
|
|
69
69
|
*
|
|
70
|
-
* Dynamo_Log.
|
|
70
|
+
* Dynamo_Log.success('token authenticated');
|
|
71
71
|
* res.setHeader('authorization', `Bearer ${token}`);
|
|
72
72
|
* next();
|
|
73
73
|
* } catch (error) {
|
|
@@ -78,7 +78,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
78
78
|
* userMessage: `Authorization failed.`,
|
|
79
79
|
* error
|
|
80
80
|
* });
|
|
81
|
-
* Dynamo_Log.
|
|
81
|
+
* Dynamo_Log.error(error?.message, error);
|
|
82
82
|
*
|
|
83
83
|
* res.status(error.status);
|
|
84
84
|
* res.send(error);
|
|
@@ -101,7 +101,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
101
101
|
* try {
|
|
102
102
|
* let token = AuthService.getTokenFromRequest(req);
|
|
103
103
|
* token = await AuthService.verifyTokenSelf(token, req?.params?.userId);
|
|
104
|
-
* Dynamo_Log.
|
|
104
|
+
* Dynamo_Log.success('selftoken authenticated');
|
|
105
105
|
*
|
|
106
106
|
* res.setHeader('authorization', `Bearer ${token}`);
|
|
107
107
|
* next();
|
|
@@ -113,7 +113,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
113
113
|
* userMessage: `Authorization failed.`,
|
|
114
114
|
* error
|
|
115
115
|
* });
|
|
116
|
-
* Dynamo_Log.
|
|
116
|
+
* Dynamo_Log.error(error?.message, error);
|
|
117
117
|
*
|
|
118
118
|
* res.status(error.status);
|
|
119
119
|
* res.send(error);
|
|
@@ -81,7 +81,7 @@ export abstract class DynamoNTS_Controller extends DynamoNTS_SingletonService {
|
|
|
81
81
|
try {
|
|
82
82
|
this.setupEndpoints();
|
|
83
83
|
} catch (error) {
|
|
84
|
-
Dynamo_Log.
|
|
84
|
+
Dynamo_Log.error(`DynamoBEController ERROR setup failed:`, error);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { Dynamo_Metadata,
|
|
2
|
+
import { Dynamo_Metadata, Dynamo_DataParams, Dynamo_DataPropertyParams, Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
3
3
|
|
|
4
4
|
import { DynamoNTS_DBService } from './dynamo-nts-db.service';
|
|
5
5
|
import { DynamoNTS_GlobalService } from './dynamo-nts-global.service';
|
|
@@ -33,7 +33,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
33
33
|
depDBServiceKey?: string;
|
|
34
34
|
private depDataDBService: DynamoNTS_DBService<any>;
|
|
35
35
|
|
|
36
|
-
dataParams:
|
|
36
|
+
dataParams: Dynamo_DataParams;
|
|
37
37
|
|
|
38
38
|
defaultErrorUserMsg =
|
|
39
39
|
`We encountered an unhandled Data Error, ` +
|
|
@@ -50,7 +50,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
50
50
|
/**
|
|
51
51
|
* DB data prams will be used to connect to usable dbService on GlobalService
|
|
52
52
|
*/
|
|
53
|
-
dataParams:
|
|
53
|
+
dataParams: Dynamo_DataParams,
|
|
54
54
|
/**
|
|
55
55
|
* Initial set for issuer to be able to follow the issuer's activity
|
|
56
56
|
*/
|
|
@@ -70,7 +70,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
70
70
|
try {
|
|
71
71
|
const dataListExists: T[] = await this.dataDBService.getAll().catch(error => {
|
|
72
72
|
if (error?.errorCode === 'NTS-DBS-GA1') {
|
|
73
|
-
Dynamo_Log.
|
|
73
|
+
Dynamo_Log.warn(`getAll ${this.dataParams.dataName} didn't found any.`);
|
|
74
74
|
return [];
|
|
75
75
|
} else {
|
|
76
76
|
throw error;
|
|
@@ -122,7 +122,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
122
122
|
|
|
123
123
|
const dataExists: T = await this.dataDBService.getDataById(id ?? this.data._id).catch(error => {
|
|
124
124
|
if (error?.errorCode == 'NTS-DBS-GI1') {
|
|
125
|
-
Dynamo_Log.
|
|
125
|
+
Dynamo_Log.warn(`getDataById ${this.dataParams.dataName} (${id ?? this.data._id}) didn't found any.`);
|
|
126
126
|
return null;
|
|
127
127
|
} else {
|
|
128
128
|
throw error;
|
|
@@ -177,7 +177,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
177
177
|
|
|
178
178
|
const dataExists: T = await this.dataDBService.getDataByDependencyId(dependencyId ?? this.data[this.depKey]).catch(error => {
|
|
179
179
|
if (error?.errorCode === 'NTS-DBS-GD2') {
|
|
180
|
-
Dynamo_Log.
|
|
180
|
+
Dynamo_Log.warn(`getDataByDependencyId ${this.dataParams.dataName} (${this.depKey}: ${dependencyId ?? this.data[this.depKey]}) didn't found any.`);
|
|
181
181
|
return null;
|
|
182
182
|
} else {
|
|
183
183
|
throw error;
|
|
@@ -232,7 +232,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
232
232
|
|
|
233
233
|
const dataListExists: T[] = await this.dataDBService.getDataListByDependencyId(dependencyId ?? this.data[this.depKey]).catch(error => {
|
|
234
234
|
if (error?.errorCode === 'NTS-DBS-GLD2') {
|
|
235
|
-
Dynamo_Log.
|
|
235
|
+
Dynamo_Log.warn(`getDataListByDependencyId ${this.dataParams.dataName} (${this.depKey}: ${dependencyId ?? this.data[this.depKey]}) didn't found any.`);
|
|
236
236
|
return [];
|
|
237
237
|
} else {
|
|
238
238
|
throw error;
|
|
@@ -293,7 +293,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
293
293
|
try {
|
|
294
294
|
const dataExists: T = await this.dataDBService.findOne(findBy).catch(error => {
|
|
295
295
|
if (error?.errorCode === 'NTS-DBS-FO1') {
|
|
296
|
-
Dynamo_Log.
|
|
296
|
+
Dynamo_Log.warn(`findData ${this.dataParams.dataName} didn't found any.`);
|
|
297
297
|
return null;
|
|
298
298
|
} else {
|
|
299
299
|
throw error;
|
|
@@ -350,7 +350,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
350
350
|
try {
|
|
351
351
|
const dataListExists: T[] = await this.dataDBService.find(findBy).catch(error => {
|
|
352
352
|
if (error?.errorCode === 'NTS-DBS-F1') {
|
|
353
|
-
Dynamo_Log.
|
|
353
|
+
Dynamo_Log.warn(`findDatas ${this.dataParams.dataName} didn't found any.`);
|
|
354
354
|
return [];
|
|
355
355
|
} else {
|
|
356
356
|
throw error;
|
|
@@ -641,7 +641,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
641
641
|
* setting up dependency dataHook by DynamoBEDataModelParams
|
|
642
642
|
*/
|
|
643
643
|
private lookForDependencyDataSettings(): void {
|
|
644
|
-
const dependencyParam:
|
|
644
|
+
const dependencyParam: Dynamo_DataPropertyParams = this.dataParams.modelParams.find((modelParams: Dynamo_DataPropertyParams) => modelParams.isDependencyHook);
|
|
645
645
|
if (dependencyParam) {
|
|
646
646
|
this.depKey = dependencyParam.key;
|
|
647
647
|
if (dependencyParam.dependencyDataName) {
|