@futdevpro/nts-dynamo 1.5.55 → 1.5.58
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/README.md +123 -0
- package/lib/_enums/data-model-type.enum.d.ts +7 -0
- package/lib/_enums/data-model-type.enum.d.ts.map +1 -1
- package/lib/_enums/data-model-type.enum.js +7 -0
- package/lib/_enums/data-model-type.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts +5 -0
- package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts.map +1 -1
- package/lib/_enums/dynamo-nts-data-service-function.enum.js +5 -1
- package/lib/_enums/dynamo-nts-data-service-function.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-route-security.enum.d.ts +6 -0
- package/lib/_enums/dynamo-nts-route-security.enum.d.ts.map +1 -1
- package/lib/_enums/dynamo-nts-route-security.enum.js +6 -0
- package/lib/_enums/dynamo-nts-route-security.enum.js.map +1 -1
- package/lib/_enums/dynamo-nts-socket-security.enum.d.ts +6 -0
- package/lib/_enums/dynamo-nts-socket-security.enum.d.ts.map +1 -1
- package/lib/_enums/dynamo-nts-socket-security.enum.js +6 -0
- package/lib/_enums/dynamo-nts-socket-security.enum.js.map +1 -1
- package/lib/_enums/http/http-call-type.enum.d.ts +4 -0
- package/lib/_enums/http/http-call-type.enum.d.ts.map +1 -1
- package/lib/_enums/http/http-call-type.enum.js +4 -0
- package/lib/_enums/http/http-call-type.enum.js.map +1 -1
- package/lib/_enums/predefined-data-types.enum.d.ts +3 -0
- package/lib/_enums/predefined-data-types.enum.d.ts.map +1 -1
- package/lib/_enums/predefined-data-types.enum.js +3 -0
- package/lib/_enums/predefined-data-types.enum.js.map +1 -1
- package/lib/_models/dynamo-nts-api-call-params.d.ts +61 -2
- package/lib/_models/dynamo-nts-api-call-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-api-call-params.js +24 -7
- package/lib/_models/dynamo-nts-api-call-params.js.map +1 -1
- package/lib/_models/dynamo-nts-app-params.d.ts +33 -1
- package/lib/_models/dynamo-nts-app-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-app-params.js +1 -1
- package/lib/_models/dynamo-nts-app-params.js.map +1 -1
- package/lib/_models/dynamo-nts-endpoint-params.d.ts +36 -1
- package/lib/_models/dynamo-nts-endpoint-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-endpoint-params.js +15 -13
- package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -1
- package/lib/_models/dynamo-nts-global-settings.d.ts +31 -0
- package/lib/_models/dynamo-nts-global-settings.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-routing-module-settings.d.ts +10 -1
- package/lib/_models/dynamo-nts-routing-module-settings.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-dictionary.d.ts +3 -0
- package/lib/_models/dynamo-nts-socket-dictionary.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-dictionary.js +3 -0
- package/lib/_models/dynamo-nts-socket-dictionary.js.map +1 -1
- package/lib/_models/dynamo-nts-socket-event-params.d.ts +1 -1
- package/lib/_models/dynamo-nts-socket-event-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-event-params.js +3 -3
- package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
- package/lib/_models/dynamo-nts-socket-service-params.d.ts +1 -1
- package/lib/_models/dynamo-nts-socket-service-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-service-params.js +3 -3
- package/lib/_models/dynamo-nts-socket-service-params.js.map +1 -1
- package/lib/_modules/usage/usage.service.js +1 -1
- package/lib/_modules/usage/usage.service.js.map +1 -1
- package/lib/_services/dynamo-nts-api.service.d.ts +17 -2
- package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-api.service.js +19 -11
- package/lib/_services/dynamo-nts-api.service.js.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.d.ts +10 -1
- package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.js +8 -8
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
- package/lib/_services/dynamo-nts-app.d.ts +30 -3
- package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app.js +19 -19
- 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.d.ts +55 -0
- package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-controller.service.js +2 -2
- package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
- package/lib/_services/dynamo-nts-data.service.d.ts +13 -1
- package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-data.service.js +19 -7
- package/lib/_services/dynamo-nts-data.service.js.map +1 -1
- package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-email.service.js +26 -22
- package/lib/_services/dynamo-nts-email.service.js.map +1 -1
- package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-global.service.js +3 -3
- package/lib/_services/dynamo-nts-global.service.js.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.js +1 -2
- package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.js +1 -2
- package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/_assets/dynamo-nts-128.png +0 -0
- package/src/_assets/dynamo-nts-256.png +0 -0
- package/src/_assets/dynamo-nts-512.png +0 -0
- package/src/_assets/dynamo-nts-64.png +0 -0
- package/src/_enums/data-model-type.enum.ts +7 -0
- package/src/_enums/dynamo-nts-data-service-function.enum.ts +5 -1
- package/src/_enums/dynamo-nts-route-security.enum.ts +6 -0
- package/src/_enums/dynamo-nts-socket-security.enum.ts +6 -0
- package/src/_enums/http/http-call-type.enum.ts +4 -0
- package/src/_enums/predefined-data-types.enum.ts +3 -0
- package/src/_models/dynamo-nts-api-call-params.ts +74 -14
- package/src/_models/dynamo-nts-app-params.ts +33 -1
- package/src/_models/dynamo-nts-endpoint-params.ts +49 -14
- package/src/_models/dynamo-nts-global-settings.ts +31 -0
- package/src/_models/dynamo-nts-routing-module-settings.ts +10 -1
- package/src/_models/dynamo-nts-socket-dictionary.ts +3 -0
- package/src/_models/dynamo-nts-socket-event-params.ts +3 -3
- package/src/_models/dynamo-nts-socket-service-params.ts +3 -3
- package/src/_modules/usage/usage.service.ts +2 -2
- package/src/_services/dynamo-nts-api.service.ts +23 -12
- package/src/_services/dynamo-nts-app-extended.ts +17 -8
- package/src/_services/dynamo-nts-app.ts +47 -20
- package/src/_services/dynamo-nts-auth.service.ts +4 -4
- package/src/_services/dynamo-nts-controller.service.ts +57 -2
- package/src/_services/dynamo-nts-data.service.ts +16 -8
- package/src/_services/dynamo-nts-email.service.ts +33 -23
- package/src/_services/dynamo-nts-global.service.ts +3 -4
- package/src/_services/dynamo-nts-routing-module.service.ts +2 -3
- package/src/_services/dynamo-nts-socket.service.ts +2 -3
- package/src/version.json +0 -2
|
@@ -6,12 +6,12 @@ import * as Https from 'https';
|
|
|
6
6
|
import * as FileSystem from 'fs';
|
|
7
7
|
import * as BodyParser from 'body-parser';
|
|
8
8
|
|
|
9
|
-
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
10
9
|
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
11
10
|
import { DynamoNTS_RouteSecurity } from '../_enums/dynamo-nts-route-security.enum';
|
|
12
11
|
import { DynamoNTS_RoutingModule } from './dynamo-nts-routing-module.service';
|
|
13
12
|
import { DynamoNTS_EndpointParams } from '../_models/dynamo-nts-endpoint-params';
|
|
14
13
|
import { dynamoNTS_GlobalSettings } from '../_constants';
|
|
14
|
+
import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* This will be the MAIN service of our server project,
|
|
@@ -27,10 +27,10 @@ import { dynamoNTS_GlobalSettings } from '../_constants';
|
|
|
27
27
|
*
|
|
28
28
|
* ...
|
|
29
29
|
*
|
|
30
|
-
*
|
|
30
|
+
* // Setting up App params, and preparing project global settings
|
|
31
31
|
* setupAppParams(): void {
|
|
32
32
|
* this.params = new DynamoNTS_AppParams({
|
|
33
|
-
* name: 'Warbots
|
|
33
|
+
* name: 'Warbots Server',
|
|
34
34
|
* title: warbotsTitleLog,
|
|
35
35
|
* version: version,
|
|
36
36
|
* dbName: 'warbots',
|
|
@@ -125,15 +125,36 @@ import { dynamoNTS_GlobalSettings } from '../_constants';
|
|
|
125
125
|
*/
|
|
126
126
|
export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Setup this in the setupAppParams(), which will be called first in the constuctor
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
*
|
|
133
|
+
* this.params = new DynamoNTS_AppParams({
|
|
134
|
+
* name: 'Warbots Server',
|
|
135
|
+
* title: warbotsTitleLog,
|
|
136
|
+
* version: version,
|
|
137
|
+
* dbName: 'warbots',
|
|
138
|
+
* });
|
|
139
|
+
*/
|
|
128
140
|
protected params: DynamoNTS_AppParams;
|
|
129
141
|
|
|
130
142
|
protected mongoose = Mongoose;
|
|
131
143
|
|
|
132
144
|
protected security: DynamoNTS_RouteSecurity;
|
|
133
145
|
|
|
146
|
+
/**
|
|
147
|
+
* setup this in the setupRoutingModules()
|
|
148
|
+
*/
|
|
134
149
|
protected httpPort?: number;
|
|
150
|
+
/**
|
|
151
|
+
* setup this in the setupRoutingModules()
|
|
152
|
+
*/
|
|
135
153
|
protected httpsPort?: number;
|
|
136
154
|
|
|
155
|
+
/**
|
|
156
|
+
* setup this in the setupRoutingModules()
|
|
157
|
+
*/
|
|
137
158
|
protected cert?: {
|
|
138
159
|
keyPath: FileSystem.PathLike,
|
|
139
160
|
certPath: FileSystem.PathLike,
|
|
@@ -143,9 +164,15 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
143
164
|
private secureExpress: Express.Application;
|
|
144
165
|
protected httpsServer: Https.Server;
|
|
145
166
|
|
|
167
|
+
/**
|
|
168
|
+
* setup this in the setupRoutingModules()
|
|
169
|
+
*/
|
|
146
170
|
protected routingModules: DynamoNTS_RoutingModule[];
|
|
147
171
|
|
|
148
|
-
|
|
172
|
+
/**
|
|
173
|
+
* setting this value to true, enables this service debug logs
|
|
174
|
+
*/
|
|
175
|
+
protected debugLog: boolean;
|
|
149
176
|
|
|
150
177
|
constructor(){
|
|
151
178
|
super();
|
|
@@ -158,7 +185,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
158
185
|
this.startDB();
|
|
159
186
|
|
|
160
187
|
this.setGlobalServiceCollection();
|
|
161
|
-
this.
|
|
188
|
+
this.debugLog = dynamoNTS_GlobalSettings.logSetup;
|
|
162
189
|
|
|
163
190
|
this.setupRoutingModules();
|
|
164
191
|
this.setSecurity();
|
|
@@ -174,10 +201,10 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
174
201
|
this.mountSecureRoutes();
|
|
175
202
|
}
|
|
176
203
|
|
|
177
|
-
if (this.
|
|
204
|
+
if (this.debugLog) console.log(`\nRoutes mounted.... server using security: ${this.security}`);
|
|
178
205
|
}
|
|
179
206
|
} catch (error) {
|
|
180
|
-
|
|
207
|
+
Dynamo_Log.logError('\nApplication start failed.\n', error);
|
|
181
208
|
}
|
|
182
209
|
}
|
|
183
210
|
|
|
@@ -187,10 +214,10 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
187
214
|
private startDB(): void {
|
|
188
215
|
this.mongoose.connection
|
|
189
216
|
.on('error', (error) => {
|
|
190
|
-
|
|
217
|
+
Dynamo_Log.logError('\nUnable to connect to MongoDB server, ERROR: ', error);
|
|
191
218
|
})
|
|
192
219
|
.once('open', () => {
|
|
193
|
-
|
|
220
|
+
Dynamo_Log.logSuccess('\nConnected to MongoDB\n');
|
|
194
221
|
});
|
|
195
222
|
|
|
196
223
|
this.mongoose.connect(
|
|
@@ -224,7 +251,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
224
251
|
});
|
|
225
252
|
}
|
|
226
253
|
});
|
|
227
|
-
|
|
254
|
+
Dynamo_Log.logError(errorMsg);
|
|
228
255
|
|
|
229
256
|
let error = new Error('Open routes cannot be established!');
|
|
230
257
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -261,7 +288,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
261
288
|
});
|
|
262
289
|
}
|
|
263
290
|
});
|
|
264
|
-
|
|
291
|
+
Dynamo_Log.logError(errorMsg);
|
|
265
292
|
|
|
266
293
|
let error = new Error('Secure routes cannot be established!');
|
|
267
294
|
let errorStack: string[] = error.stack.split('\n');
|
|
@@ -307,30 +334,30 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
307
334
|
if (this.security !== DynamoNTS_RouteSecurity.open) {
|
|
308
335
|
this.httpsServer
|
|
309
336
|
.listen(this.httpsPort, 'localhost', 0, () => {
|
|
310
|
-
|
|
337
|
+
Dynamo_Log.logSuccess(`\nHTTPS (secure) server is listening on port ${this.httpsPort}\n`);
|
|
311
338
|
})
|
|
312
339
|
.on('error', (error) => {
|
|
313
|
-
|
|
340
|
+
Dynamo_Log.logError(`\nHTTPS (secure) server ERROR`, error);
|
|
314
341
|
})
|
|
315
342
|
.on('uncaughtException', (ex) => {
|
|
316
|
-
|
|
343
|
+
Dynamo_Log.logWarning(`\nHTTPS (secure) server uncaughtException`, ex);
|
|
317
344
|
});
|
|
318
345
|
}
|
|
319
346
|
|
|
320
347
|
if (this.security !== DynamoNTS_RouteSecurity.secure) {
|
|
321
348
|
this.openExpress
|
|
322
349
|
.listen(this.httpPort, () => {
|
|
323
|
-
|
|
350
|
+
Dynamo_Log.logSuccess(`\nHTTP (-open-) server is listening on port ${this.httpPort}\n`);
|
|
324
351
|
})
|
|
325
352
|
.on('error', (error) => {
|
|
326
|
-
|
|
353
|
+
Dynamo_Log.logError(`\nHTTP (-open-) server ERROR`, error);
|
|
327
354
|
})
|
|
328
355
|
.on('uncaughtException', (ex) => {
|
|
329
|
-
|
|
356
|
+
Dynamo_Log.logWarning(`\nHTTP (-open-) server uncaughtException`, ex);
|
|
330
357
|
});
|
|
331
358
|
}
|
|
332
359
|
} catch (error) {
|
|
333
|
-
|
|
360
|
+
Dynamo_Log.logError(`startExpresses failed...`, error);
|
|
334
361
|
}
|
|
335
362
|
}
|
|
336
363
|
|
|
@@ -340,7 +367,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
340
367
|
private mountSecureRoutes (): void {
|
|
341
368
|
this.routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
342
369
|
if (module.security !== DynamoNTS_RouteSecurity.open) {
|
|
343
|
-
if (this.
|
|
370
|
+
if (this.debugLog) console.log(`route mount (secure): ${module.route}`);
|
|
344
371
|
const existingRoutes: DynamoNTS_RoutingModule[] = this.routingModules.filter(
|
|
345
372
|
(mod: DynamoNTS_RoutingModule) => mod.route === module.route);
|
|
346
373
|
if (1 < existingRoutes.length) {
|
|
@@ -362,7 +389,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
362
389
|
private mountOpenRoutes (): void {
|
|
363
390
|
this.routingModules.forEach((module: DynamoNTS_RoutingModule) => {
|
|
364
391
|
if (module.security !== DynamoNTS_RouteSecurity.secure) {
|
|
365
|
-
if (this.
|
|
392
|
+
if (this.debugLog) console.log(`route mount (open): ${module.route}`);
|
|
366
393
|
const existingRoutes: DynamoNTS_RoutingModule[] = this.routingModules.filter(
|
|
367
394
|
(mod: DynamoNTS_RoutingModule) => mod.route === module.route);
|
|
368
395
|
if (1 < existingRoutes.length) {
|
|
@@ -65,7 +65,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
65
65
|
* let token = AuthService.getTokenFromRequest(req);
|
|
66
66
|
* token = await AuthService.verifyToken(token);
|
|
67
67
|
*
|
|
68
|
-
*
|
|
68
|
+
* Dynamo_Log.logSuccess('token authenticated');
|
|
69
69
|
* res.setHeader('authorization', `Bearer ${token}`);
|
|
70
70
|
* next();
|
|
71
71
|
* } catch (error) {
|
|
@@ -76,7 +76,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
76
76
|
* userMessage: `Authorization failed.`,
|
|
77
77
|
* error
|
|
78
78
|
* });
|
|
79
|
-
*
|
|
79
|
+
* Dynamo_Log.logError(error?.message, error);
|
|
80
80
|
*
|
|
81
81
|
* res.status(error.status);
|
|
82
82
|
* res.send(error);
|
|
@@ -99,7 +99,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
99
99
|
* try {
|
|
100
100
|
* let token = AuthService.getTokenFromRequest(req);
|
|
101
101
|
* token = await AuthService.verifyTokenSelf(token, req?.params?.userId);
|
|
102
|
-
*
|
|
102
|
+
* Dynamo_Log.logSuccess('selftoken authenticated');
|
|
103
103
|
*
|
|
104
104
|
* res.setHeader('authorization', `Bearer ${token}`);
|
|
105
105
|
* next();
|
|
@@ -111,7 +111,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
111
111
|
* userMessage: `Authorization failed.`,
|
|
112
112
|
* error
|
|
113
113
|
* });
|
|
114
|
-
*
|
|
114
|
+
* Dynamo_Log.logError(error?.message, error);
|
|
115
115
|
*
|
|
116
116
|
* res.status(error.status);
|
|
117
117
|
* res.send(error);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
import { Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
3
4
|
import { DynamoNTS_EndpointParams } from '../_models/dynamo-nts-endpoint-params';
|
|
4
|
-
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
5
5
|
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -46,6 +46,33 @@ import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
|
46
46
|
*/
|
|
47
47
|
export abstract class DynamoNTS_Controller extends DynamoNTS_SingletonService {
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* setup this in the setupEndpoints(), which will be called on the construcion
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
*
|
|
54
|
+
* this.endpoints = [
|
|
55
|
+
* new DynamoNTS_EndpointParams({
|
|
56
|
+
* name: 'getUserMatchStatistics',
|
|
57
|
+
* type: HttpCallType.get,
|
|
58
|
+
* endpoint: '/get/user-match-statistics/:userId',
|
|
59
|
+
* preProcessess: [ this.authService.authenticateTokenSelf ],
|
|
60
|
+
* tasks: [
|
|
61
|
+
* async (req: Request, res: Response) => {
|
|
62
|
+
* const userMatchStatistics = new UserMatchStatisticsService({
|
|
63
|
+
* data: { userId: req.params.userId }
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* await userMatchStatistics.getDataByDependencyId();
|
|
67
|
+
*
|
|
68
|
+
* res.send(
|
|
69
|
+
* userMatchStatistics.data
|
|
70
|
+
* );
|
|
71
|
+
* }
|
|
72
|
+
* ]
|
|
73
|
+
* }),
|
|
74
|
+
* ];
|
|
75
|
+
*/
|
|
49
76
|
endpoints: DynamoNTS_EndpointParams[];
|
|
50
77
|
|
|
51
78
|
protected constructor(){
|
|
@@ -54,12 +81,40 @@ export abstract class DynamoNTS_Controller extends DynamoNTS_SingletonService {
|
|
|
54
81
|
try {
|
|
55
82
|
this.setupEndpoints();
|
|
56
83
|
} catch (error) {
|
|
57
|
-
|
|
84
|
+
Dynamo_Log.logError(`DynamoBEController ERROR setup failed:`, error);
|
|
58
85
|
}
|
|
59
86
|
}
|
|
60
87
|
|
|
61
88
|
/**
|
|
62
89
|
* You must setup endpoints and required services in this function
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
*
|
|
93
|
+
* setupEndpoints(): void {
|
|
94
|
+
* this.authService = AuthService.getInstance();
|
|
95
|
+
*
|
|
96
|
+
* this.endpoints = [
|
|
97
|
+
* new DynamoNTS_EndpointParams({
|
|
98
|
+
* name: 'getUserMatchStatistics',
|
|
99
|
+
* type: HttpCallType.get,
|
|
100
|
+
* endpoint: '/get/user-match-statistics/:userId',
|
|
101
|
+
* preProcessess: [ this.authService.authenticateTokenSelf ],
|
|
102
|
+
* tasks: [
|
|
103
|
+
* async (req: Request, res: Response) => {
|
|
104
|
+
* const userMatchStatistics = new UserMatchStatisticsService({
|
|
105
|
+
* data: { userId: req.params.userId }
|
|
106
|
+
* });
|
|
107
|
+
*
|
|
108
|
+
* await userMatchStatistics.getDataByDependencyId();
|
|
109
|
+
*
|
|
110
|
+
* res.send(
|
|
111
|
+
* userMatchStatistics.data
|
|
112
|
+
* );
|
|
113
|
+
* }
|
|
114
|
+
* ]
|
|
115
|
+
* }),
|
|
116
|
+
* ];
|
|
117
|
+
* }
|
|
63
118
|
*/
|
|
64
119
|
abstract setupEndpoints(): void
|
|
65
120
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import { Dynamo_Metadata, DynamoNTS_DataParams, DynamoNTS_DataPropertyParams, Dynamo_Error,
|
|
2
|
+
import { Dynamo_Metadata, DynamoNTS_DataParams, DynamoNTS_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';
|
|
6
|
-
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Basic Data Service that is connected to the relevant DBServices
|
|
@@ -40,8 +39,17 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
40
39
|
defaultValidationErrorUserMsg = `We encountered an unhandled Validation Error, please contact the responsible development team.`;
|
|
41
40
|
|
|
42
41
|
constructor(
|
|
42
|
+
/**
|
|
43
|
+
* Initial data, this will be used by functions on default
|
|
44
|
+
*/
|
|
43
45
|
data: T,
|
|
46
|
+
/**
|
|
47
|
+
* DB data prams will be used to connect to usable dbService on GlobalService
|
|
48
|
+
*/
|
|
44
49
|
dataParams: DynamoNTS_DataParams,
|
|
50
|
+
/**
|
|
51
|
+
* Initial set for issuer to be able to follow the issuer's activity
|
|
52
|
+
*/
|
|
45
53
|
issuer: string,
|
|
46
54
|
) {
|
|
47
55
|
this.dataDBService = DynamoNTS_GlobalService.getDBService<T>(dataParams);
|
|
@@ -58,7 +66,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
58
66
|
try {
|
|
59
67
|
const dataListExists: T[] = await this.dataDBService.getAll().catch(error => {
|
|
60
68
|
if (error?.errorCodes?.includes('NTS-DBS-GA1')) {
|
|
61
|
-
|
|
69
|
+
Dynamo_Log.logWarning(`getAll ${this.dataParams.dataName} didn't found any.`);
|
|
62
70
|
return [];
|
|
63
71
|
} else {
|
|
64
72
|
throw error;
|
|
@@ -110,7 +118,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
110
118
|
|
|
111
119
|
const dataExists: T = await this.dataDBService.getDataById(id ?? this.data._id).catch(error => {
|
|
112
120
|
if (error?.errorCodes?.includes('NTS-DBS-GI1')) {
|
|
113
|
-
|
|
121
|
+
Dynamo_Log.logWarning(`getDataById ${this.dataParams.dataName} (${id ?? this.data._id}) didn't found any.`);
|
|
114
122
|
return null;
|
|
115
123
|
} else {
|
|
116
124
|
throw error;
|
|
@@ -165,7 +173,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
165
173
|
|
|
166
174
|
const dataExists: T = await this.dataDBService.getDataByDependencyId(dependencyId ?? this.data[this.depKey]).catch(error => {
|
|
167
175
|
if (error?.errorCodes?.includes('NTS-DBS-GD2')) {
|
|
168
|
-
|
|
176
|
+
Dynamo_Log.logWarning(`getDataByDependencyId ${this.dataParams.dataName} (${this.depKey}: ${dependencyId ?? this.data[this.depKey]}) didn't found any.`);
|
|
169
177
|
return null;
|
|
170
178
|
} else {
|
|
171
179
|
throw error;
|
|
@@ -220,7 +228,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
220
228
|
|
|
221
229
|
const dataListExists: T[] = await this.dataDBService.getDataListByDependencyId(dependencyId ?? this.data[this.depKey]).catch(error => {
|
|
222
230
|
if (error?.errorCodes?.includes('NTS-DBS-GLD2')) {
|
|
223
|
-
|
|
231
|
+
Dynamo_Log.logWarning(`getDataListByDependencyId ${this.dataParams.dataName} (${this.depKey}: ${dependencyId ?? this.data[this.depKey]}) didn't found any.`);
|
|
224
232
|
return [];
|
|
225
233
|
} else {
|
|
226
234
|
throw error;
|
|
@@ -281,7 +289,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
281
289
|
try {
|
|
282
290
|
const dataExists: T = await this.dataDBService.findOne(findBy).catch(error => {
|
|
283
291
|
if (error?.errorCodes?.includes('NTS-DBS-FO1')) {
|
|
284
|
-
|
|
292
|
+
Dynamo_Log.logWarning(`findData ${this.dataParams.dataName} didn't found any.`);
|
|
285
293
|
return null;
|
|
286
294
|
} else {
|
|
287
295
|
throw error;
|
|
@@ -338,7 +346,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
338
346
|
try {
|
|
339
347
|
const dataListExists: T[] = await this.dataDBService.find(findBy).catch(error => {
|
|
340
348
|
if (error?.errorCodes?.includes('NTS-DBS-F1')) {
|
|
341
|
-
|
|
349
|
+
Dynamo_Log.logWarning(`findDatas ${this.dataParams.dataName} didn't found any.`);
|
|
342
350
|
return [];
|
|
343
351
|
} else {
|
|
344
352
|
throw error;
|
|
@@ -3,9 +3,7 @@ import * as FileSystem from 'fs';
|
|
|
3
3
|
import * as Path from 'path';
|
|
4
4
|
import * as NodeMailer from 'nodemailer';
|
|
5
5
|
import { Options as MailOptions, Attachment } from 'nodemailer/lib/mailer';
|
|
6
|
-
import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
|
|
7
|
-
|
|
8
|
-
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
6
|
+
import { Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
*
|
|
@@ -57,7 +55,7 @@ export class DynamoNTS_EmailService {
|
|
|
57
55
|
this.constructionFinished();
|
|
58
56
|
}
|
|
59
57
|
} catch (error) {
|
|
60
|
-
|
|
58
|
+
Dynamo_Log.logError(`\nDynamoBEEmailService ERROR, The emailService construction failed for ${set.email}.`, new Error());
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
|
|
@@ -65,7 +63,7 @@ export class DynamoNTS_EmailService {
|
|
|
65
63
|
*
|
|
66
64
|
*/
|
|
67
65
|
private constructionFinished(): void {
|
|
68
|
-
|
|
66
|
+
Dynamo_Log.logSuccess(`\nEmailService construction (${this.senderName}) Finished!\n`)
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
/**
|
|
@@ -87,15 +85,25 @@ export class DynamoNTS_EmailService {
|
|
|
87
85
|
|
|
88
86
|
if (set.content) {
|
|
89
87
|
content = set.content
|
|
90
|
-
} else
|
|
91
|
-
if (!
|
|
88
|
+
} else {
|
|
89
|
+
if (!set.useTemplate) {
|
|
92
90
|
throw new Dynamo_Error({
|
|
93
91
|
errorCode: 'NTS-ES4-101',
|
|
94
92
|
addECToUserMsg: true,
|
|
93
|
+
message: 'No content setting passsed to emailSending!',
|
|
94
|
+
userMessage: this.defaultErrorUserMsg,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!this.templates[set.useTemplate]) {
|
|
99
|
+
throw new Dynamo_Error({
|
|
100
|
+
errorCode: 'NTS-ES4-102',
|
|
101
|
+
addECToUserMsg: true,
|
|
95
102
|
message: `No email template found with this parameter! (${set.useTemplate})`,
|
|
96
103
|
userMessage: this.defaultErrorUserMsg
|
|
97
104
|
});
|
|
98
105
|
}
|
|
106
|
+
|
|
99
107
|
content = this.templates[set.useTemplate];
|
|
100
108
|
|
|
101
109
|
if (0 < this.templatePropertyKeys[set.useTemplate].length) {
|
|
@@ -104,9 +112,10 @@ export class DynamoNTS_EmailService {
|
|
|
104
112
|
this.templatePropertyKeys[set.useTemplate].forEach((key: string, index: number) => {
|
|
105
113
|
props += `${key}${index != this.templatePropertyKeys[set.useTemplate].length - 1 ? ', ' : ''}`;
|
|
106
114
|
});
|
|
107
|
-
|
|
115
|
+
Dynamo_Log.logError('\nDynamoBEEmailService ERROR: INVALID sendEmail settings', set);
|
|
116
|
+
|
|
108
117
|
throw new Dynamo_Error({
|
|
109
|
-
errorCode: 'NTS-ES4-
|
|
118
|
+
errorCode: 'NTS-ES4-103',
|
|
110
119
|
addECToUserMsg: true,
|
|
111
120
|
message: `TemplateProperties missing! properties needed: ${props}`,
|
|
112
121
|
userMessage: this.defaultErrorUserMsg
|
|
@@ -114,19 +123,12 @@ export class DynamoNTS_EmailService {
|
|
|
114
123
|
}
|
|
115
124
|
this.templatePropertyKeys[set.useTemplate].forEach((propertyKey: string) => {
|
|
116
125
|
if (!set.templateProperties[propertyKey]) {
|
|
117
|
-
|
|
126
|
+
Dynamo_Log.logError(`TemplateProperty missing! (${propertyKey})`);
|
|
118
127
|
}
|
|
119
128
|
const reg = new RegExp(`{{${propertyKey}}}`, 'g')
|
|
120
129
|
content = content.replace(reg, set.templateProperties[propertyKey]);
|
|
121
130
|
});
|
|
122
131
|
}
|
|
123
|
-
} else {
|
|
124
|
-
throw new Dynamo_Error({
|
|
125
|
-
errorCode: 'NTS-ES4-100',
|
|
126
|
-
addECToUserMsg: true,
|
|
127
|
-
message: 'No content setting passsed to emailSending!',
|
|
128
|
-
userMessage: this.defaultErrorUserMsg,
|
|
129
|
-
});
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
let mailOptions: MailOptions = {
|
|
@@ -148,8 +150,13 @@ export class DynamoNTS_EmailService {
|
|
|
148
150
|
});
|
|
149
151
|
});
|
|
150
152
|
} catch (error) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
throw new Dynamo_Error({
|
|
154
|
+
errorCode: 'NTS-ES4-100',
|
|
155
|
+
addECToUserMsg: true,
|
|
156
|
+
message: `SendEmail failed!`,
|
|
157
|
+
userMessage: this.defaultErrorUserMsg,
|
|
158
|
+
error
|
|
159
|
+
});
|
|
153
160
|
}
|
|
154
161
|
}
|
|
155
162
|
|
|
@@ -167,7 +174,7 @@ export class DynamoNTS_EmailService {
|
|
|
167
174
|
templatePath = Path.join(rootPath, templatePath);
|
|
168
175
|
FileSystem.readFile(templatePath, 'utf8' , (err, template) => {
|
|
169
176
|
if (err) {
|
|
170
|
-
|
|
177
|
+
Dynamo_Log.logError(`\nDynamoBEEmailService readFile ERROR (0), Couldn't load email template; ${templateName} from ${templatePath}\nerror:\n`, err, '\n');
|
|
171
178
|
reject(err);
|
|
172
179
|
return;
|
|
173
180
|
} else {
|
|
@@ -183,7 +190,7 @@ export class DynamoNTS_EmailService {
|
|
|
183
190
|
});
|
|
184
191
|
});
|
|
185
192
|
} catch (error) {
|
|
186
|
-
|
|
193
|
+
Dynamo_Log.logError(`\nDynamoBEEmailService ERROR (1), Couldn't load email template; ${templateName} from ${templatePath}`, new Error());
|
|
187
194
|
}
|
|
188
195
|
}
|
|
189
196
|
|
|
@@ -197,9 +204,10 @@ export class DynamoNTS_EmailService {
|
|
|
197
204
|
const propertyKeys: string[] = [];
|
|
198
205
|
let propertyOpenTagIndex = template.indexOf('{{');
|
|
199
206
|
let propertyCloseTagIndex = template.indexOf('}}', propertyOpenTagIndex + 2);
|
|
207
|
+
|
|
200
208
|
while (propertyOpenTagIndex >= 0) {
|
|
201
209
|
if (propertyCloseTagIndex === -1) {
|
|
202
|
-
|
|
210
|
+
Dynamo_Log.logError(`\nDynamoBEEmailService ERROR, missing closing tag from email template! (${propertyOpenTagIndex} -)`, propertyKeys);
|
|
203
211
|
throw new Dynamo_Error({
|
|
204
212
|
errorCode: 'NTS-ES4-200',
|
|
205
213
|
addECToUserMsg: true,
|
|
@@ -207,17 +215,19 @@ export class DynamoNTS_EmailService {
|
|
|
207
215
|
userMessage: this.defaultErrorUserMsg
|
|
208
216
|
});
|
|
209
217
|
}
|
|
218
|
+
|
|
210
219
|
const newKey: string = template.substring(propertyOpenTagIndex + 2, propertyCloseTagIndex);
|
|
211
220
|
if (!propertyKeys.includes(newKey)) {
|
|
212
221
|
propertyKeys.push(newKey);
|
|
213
222
|
}
|
|
223
|
+
|
|
214
224
|
propertyOpenTagIndex = template.indexOf('{{', propertyOpenTagIndex + 2);
|
|
215
225
|
propertyCloseTagIndex = template.indexOf('}}', propertyOpenTagIndex + 2);
|
|
216
226
|
}
|
|
217
227
|
// console.log('\n\n\nTEST propertyKeys: ', propertyKeys);
|
|
218
228
|
return propertyKeys;
|
|
219
229
|
} catch (error) {
|
|
220
|
-
|
|
230
|
+
Dynamo_Log.logError(`\nDynamoBEEmailService ERROR, getTemplatePropertyKeys ERROR`, new Error(), '\ntemplate:\n', template);
|
|
221
231
|
}
|
|
222
232
|
}
|
|
223
233
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import { Dynamo_Metadata, DynamoNTS_DataParams } from '@futdevpro/fsm-dynamo';
|
|
3
|
+
import { Dynamo_Metadata, DynamoNTS_DataParams, Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
4
4
|
|
|
5
5
|
import { DynamoNTS_AuthService } from './dynamo-nts-auth.service';
|
|
6
6
|
import { DynamoNTS_DBServiceCollection } from './dynamo-nts-db-service-collection.service';
|
|
7
7
|
import { DynamoNTS_DBService } from './dynamo-nts-db.service';
|
|
8
8
|
import { DynamoNTS_EmailServiceCollection } from './dynamo-nts-email-service-collection.service';
|
|
9
|
-
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
10
9
|
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
11
10
|
import { DynamoNTS_SocketServiceCollection } from './dynamo-nts-socket-service-collection.service';
|
|
12
11
|
import { DynamoNTS_SocketService } from './dynamo-nts-socket.service';
|
|
@@ -57,14 +56,14 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
57
56
|
try {
|
|
58
57
|
this.instance.dbServiceCollection[dbModel.dataName] = new DynamoNTS_DBService(dbModel);
|
|
59
58
|
} catch (error) {
|
|
60
|
-
|
|
59
|
+
Dynamo_Log.logError(`\nFailed to create DynamoBEDBService (${dbModel.dataName}).\n`, dbModel, `\n`, error);
|
|
61
60
|
}
|
|
62
61
|
});
|
|
63
62
|
|
|
64
63
|
this.instance.authService = set.authService;
|
|
65
64
|
this.instance.emailServiceCollection = set.emailServiceCollection;
|
|
66
65
|
} catch (error) {
|
|
67
|
-
|
|
66
|
+
Dynamo_Log.logError('\nsetServices failed on DBE_Global_S.\n', error);
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
import { Router } from 'express';
|
|
3
|
-
import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
|
|
3
|
+
import { Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
4
4
|
|
|
5
5
|
import { dynamoNTS_GlobalSettings } from '../_constants/dynamo-nts-global-settings';
|
|
6
6
|
import { DynamoNTS_RouteSecurity } from '../_enums/dynamo-nts-route-security.enum';
|
|
7
7
|
import { HttpCallType } from '../_enums/http/http-call-type.enum';
|
|
8
8
|
import { DynamoNTS_EndpointParams } from '../_models/dynamo-nts-endpoint-params';
|
|
9
9
|
import { DynamoNTS_Controller } from './dynamo-nts-controller.service';
|
|
10
|
-
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
11
10
|
import { DynamoNTS_RoutingModuleSettings } from '../_models/dynamo-nts-routing-module-settings';
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -78,7 +77,7 @@ export class DynamoNTS_RoutingModule {
|
|
|
78
77
|
|
|
79
78
|
if (this.log) console.log(`routing module setup done: ${this.route} serurity: ${this.security}\n`);
|
|
80
79
|
} catch (error) {
|
|
81
|
-
|
|
80
|
+
Dynamo_Log.logError(`Routing module setup failed (${this.route})`, error);
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
import * as SocketIO from 'socket.io';
|
|
3
3
|
|
|
4
4
|
import { dynamoNTS_GlobalSettings } from '../_constants/dynamo-nts-global-settings';
|
|
5
|
-
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
6
5
|
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
7
6
|
import { DynamoNTS_SocketEventParams } from '../_models/dynamo-nts-socket-event-params';
|
|
8
7
|
import { DynamoNTS_SocketEvent } from '../_enums/http/socket-event.enum';
|
|
9
8
|
import { DynamoNTS_GlobalService } from './dynamo-nts-global.service';
|
|
10
|
-
import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
|
|
9
|
+
import { Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
|
|
11
10
|
import { DynamoNTS_SocketServiceParams } from '../_models/dynamo-nts-socket-service-params';
|
|
12
11
|
import { DynamoNTS_SocketDictionary } from '../_models/dynamo-nts-socket-dictionary';
|
|
13
12
|
import { DynamoNTS_SocketSecurity } from '../_enums/dynamo-nts-socket-security.enum';
|
|
@@ -46,7 +45,7 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
|
|
|
46
45
|
|
|
47
46
|
if (this.log) console.log(`Socket Controller setup done: ${this.params.name} (${this.params.port}) serurity: ${this.params.security}\n`);
|
|
48
47
|
} catch (error) {
|
|
49
|
-
|
|
48
|
+
Dynamo_Log.logError(`Socket Controller setup failed: ${this.params.name} (${this.params.port})`, error);
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
|
package/src/version.json
DELETED