@futdevpro/nts-dynamo 1.5.55 → 1.5.60
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 +21 -12
- 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-auth.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-auth.service.js +2 -1
- package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
- 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 +23 -9
- package/lib/_services/dynamo-nts-data.service.js.map +1 -1
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-db.service.js +2 -1
- package/lib/_services/dynamo-nts-db.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 +28 -23
- 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 +3 -3
- 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 +3 -3
- 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 +26 -13
- 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 +7 -5
- package/src/_services/dynamo-nts-controller.service.ts +57 -2
- package/src/_services/dynamo-nts-data.service.ts +22 -10
- package/src/_services/dynamo-nts-db.service.ts +3 -1
- package/src/_services/dynamo-nts-email.service.ts +36 -24
- package/src/_services/dynamo-nts-global.service.ts +3 -4
- package/src/_services/dynamo-nts-routing-module.service.ts +5 -4
- package/src/_services/dynamo-nts-socket.service.ts +5 -4
- 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) {
|
|
@@ -19,7 +19,9 @@ import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
|
19
19
|
*/
|
|
20
20
|
export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
21
21
|
|
|
22
|
-
static defaultErrorUserMsg =
|
|
22
|
+
static defaultErrorUserMsg =
|
|
23
|
+
`We encountered an unhandled BackEnd Auth Error, ` +
|
|
24
|
+
`\nplease contact the responsible development team.`;
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* this function returns the 'authorization' header from the Request,
|
|
@@ -65,7 +67,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
65
67
|
* let token = AuthService.getTokenFromRequest(req);
|
|
66
68
|
* token = await AuthService.verifyToken(token);
|
|
67
69
|
*
|
|
68
|
-
*
|
|
70
|
+
* Dynamo_Log.logSuccess('token authenticated');
|
|
69
71
|
* res.setHeader('authorization', `Bearer ${token}`);
|
|
70
72
|
* next();
|
|
71
73
|
* } catch (error) {
|
|
@@ -76,7 +78,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
76
78
|
* userMessage: `Authorization failed.`,
|
|
77
79
|
* error
|
|
78
80
|
* });
|
|
79
|
-
*
|
|
81
|
+
* Dynamo_Log.logError(error?.message, error);
|
|
80
82
|
*
|
|
81
83
|
* res.status(error.status);
|
|
82
84
|
* res.send(error);
|
|
@@ -99,7 +101,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
99
101
|
* try {
|
|
100
102
|
* let token = AuthService.getTokenFromRequest(req);
|
|
101
103
|
* token = await AuthService.verifyTokenSelf(token, req?.params?.userId);
|
|
102
|
-
*
|
|
104
|
+
* Dynamo_Log.logSuccess('selftoken authenticated');
|
|
103
105
|
*
|
|
104
106
|
* res.setHeader('authorization', `Bearer ${token}`);
|
|
105
107
|
* next();
|
|
@@ -111,7 +113,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
111
113
|
* userMessage: `Authorization failed.`,
|
|
112
114
|
* error
|
|
113
115
|
* });
|
|
114
|
-
*
|
|
116
|
+
* Dynamo_Log.logError(error?.message, error);
|
|
115
117
|
*
|
|
116
118
|
* res.status(error.status);
|
|
117
119
|
* 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
|
|
@@ -36,12 +35,25 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
36
35
|
|
|
37
36
|
dataParams: DynamoNTS_DataParams;
|
|
38
37
|
|
|
39
|
-
defaultErrorUserMsg =
|
|
40
|
-
|
|
38
|
+
defaultErrorUserMsg =
|
|
39
|
+
`We encountered an unhandled Data Error, ` +
|
|
40
|
+
`\nplease contact the responsible development team.`;
|
|
41
|
+
defaultValidationErrorUserMsg =
|
|
42
|
+
`We encountered an unhandled Validation Error, ` +
|
|
43
|
+
`\nplease contact the responsible development team.`;
|
|
41
44
|
|
|
42
45
|
constructor(
|
|
46
|
+
/**
|
|
47
|
+
* Initial data, this will be used by functions on default
|
|
48
|
+
*/
|
|
43
49
|
data: T,
|
|
50
|
+
/**
|
|
51
|
+
* DB data prams will be used to connect to usable dbService on GlobalService
|
|
52
|
+
*/
|
|
44
53
|
dataParams: DynamoNTS_DataParams,
|
|
54
|
+
/**
|
|
55
|
+
* Initial set for issuer to be able to follow the issuer's activity
|
|
56
|
+
*/
|
|
45
57
|
issuer: string,
|
|
46
58
|
) {
|
|
47
59
|
this.dataDBService = DynamoNTS_GlobalService.getDBService<T>(dataParams);
|
|
@@ -58,7 +70,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
58
70
|
try {
|
|
59
71
|
const dataListExists: T[] = await this.dataDBService.getAll().catch(error => {
|
|
60
72
|
if (error?.errorCodes?.includes('NTS-DBS-GA1')) {
|
|
61
|
-
|
|
73
|
+
Dynamo_Log.logWarning(`getAll ${this.dataParams.dataName} didn't found any.`);
|
|
62
74
|
return [];
|
|
63
75
|
} else {
|
|
64
76
|
throw error;
|
|
@@ -110,7 +122,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
110
122
|
|
|
111
123
|
const dataExists: T = await this.dataDBService.getDataById(id ?? this.data._id).catch(error => {
|
|
112
124
|
if (error?.errorCodes?.includes('NTS-DBS-GI1')) {
|
|
113
|
-
|
|
125
|
+
Dynamo_Log.logWarning(`getDataById ${this.dataParams.dataName} (${id ?? this.data._id}) didn't found any.`);
|
|
114
126
|
return null;
|
|
115
127
|
} else {
|
|
116
128
|
throw error;
|
|
@@ -165,7 +177,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
165
177
|
|
|
166
178
|
const dataExists: T = await this.dataDBService.getDataByDependencyId(dependencyId ?? this.data[this.depKey]).catch(error => {
|
|
167
179
|
if (error?.errorCodes?.includes('NTS-DBS-GD2')) {
|
|
168
|
-
|
|
180
|
+
Dynamo_Log.logWarning(`getDataByDependencyId ${this.dataParams.dataName} (${this.depKey}: ${dependencyId ?? this.data[this.depKey]}) didn't found any.`);
|
|
169
181
|
return null;
|
|
170
182
|
} else {
|
|
171
183
|
throw error;
|
|
@@ -220,7 +232,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
220
232
|
|
|
221
233
|
const dataListExists: T[] = await this.dataDBService.getDataListByDependencyId(dependencyId ?? this.data[this.depKey]).catch(error => {
|
|
222
234
|
if (error?.errorCodes?.includes('NTS-DBS-GLD2')) {
|
|
223
|
-
|
|
235
|
+
Dynamo_Log.logWarning(`getDataListByDependencyId ${this.dataParams.dataName} (${this.depKey}: ${dependencyId ?? this.data[this.depKey]}) didn't found any.`);
|
|
224
236
|
return [];
|
|
225
237
|
} else {
|
|
226
238
|
throw error;
|
|
@@ -281,7 +293,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
281
293
|
try {
|
|
282
294
|
const dataExists: T = await this.dataDBService.findOne(findBy).catch(error => {
|
|
283
295
|
if (error?.errorCodes?.includes('NTS-DBS-FO1')) {
|
|
284
|
-
|
|
296
|
+
Dynamo_Log.logWarning(`findData ${this.dataParams.dataName} didn't found any.`);
|
|
285
297
|
return null;
|
|
286
298
|
} else {
|
|
287
299
|
throw error;
|
|
@@ -338,7 +350,7 @@ export class DynamoNTS_DataService<T extends Dynamo_Metadata> {
|
|
|
338
350
|
try {
|
|
339
351
|
const dataListExists: T[] = await this.dataDBService.find(findBy).catch(error => {
|
|
340
352
|
if (error?.errorCodes?.includes('NTS-DBS-F1')) {
|
|
341
|
-
|
|
353
|
+
Dynamo_Log.logWarning(`findDatas ${this.dataParams.dataName} didn't found any.`);
|
|
342
354
|
return [];
|
|
343
355
|
} else {
|
|
344
356
|
throw error;
|
|
@@ -11,7 +11,9 @@ export class DynamoNTS_DBService<T extends Dynamo_Metadata> {
|
|
|
11
11
|
|
|
12
12
|
private depDataName: string;
|
|
13
13
|
|
|
14
|
-
defaultErrorUserMsg =
|
|
14
|
+
defaultErrorUserMsg =
|
|
15
|
+
`We encountered an unhandled DB Error, ` +
|
|
16
|
+
`\nplease contact the responsible development team.`;
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* @param dataName name the model
|
|
@@ -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
|
*
|
|
@@ -22,7 +20,9 @@ export class DynamoNTS_EmailService {
|
|
|
22
20
|
} = {};
|
|
23
21
|
private templateLoadingInProgressCounter = 0;
|
|
24
22
|
|
|
25
|
-
defaultErrorUserMsg =
|
|
23
|
+
defaultErrorUserMsg =
|
|
24
|
+
`We encountered an uncought Email Service Error, ` +
|
|
25
|
+
`\nplease contact the responsible development team.`;
|
|
26
26
|
|
|
27
27
|
constructor (
|
|
28
28
|
set: {
|
|
@@ -57,7 +57,7 @@ export class DynamoNTS_EmailService {
|
|
|
57
57
|
this.constructionFinished();
|
|
58
58
|
}
|
|
59
59
|
} catch (error) {
|
|
60
|
-
|
|
60
|
+
Dynamo_Log.logError(`\nDynamoBEEmailService ERROR, The emailService construction failed for ${set.email}.`, new Error());
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -65,7 +65,7 @@ export class DynamoNTS_EmailService {
|
|
|
65
65
|
*
|
|
66
66
|
*/
|
|
67
67
|
private constructionFinished(): void {
|
|
68
|
-
|
|
68
|
+
Dynamo_Log.logSuccess(`\nEmailService construction (${this.senderName}) Finished!\n`)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -87,15 +87,25 @@ export class DynamoNTS_EmailService {
|
|
|
87
87
|
|
|
88
88
|
if (set.content) {
|
|
89
89
|
content = set.content
|
|
90
|
-
} else
|
|
91
|
-
if (!
|
|
90
|
+
} else {
|
|
91
|
+
if (!set.useTemplate) {
|
|
92
92
|
throw new Dynamo_Error({
|
|
93
93
|
errorCode: 'NTS-ES4-101',
|
|
94
94
|
addECToUserMsg: true,
|
|
95
|
+
message: 'No content setting passsed to emailSending!',
|
|
96
|
+
userMessage: this.defaultErrorUserMsg,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!this.templates[set.useTemplate]) {
|
|
101
|
+
throw new Dynamo_Error({
|
|
102
|
+
errorCode: 'NTS-ES4-102',
|
|
103
|
+
addECToUserMsg: true,
|
|
95
104
|
message: `No email template found with this parameter! (${set.useTemplate})`,
|
|
96
105
|
userMessage: this.defaultErrorUserMsg
|
|
97
106
|
});
|
|
98
107
|
}
|
|
108
|
+
|
|
99
109
|
content = this.templates[set.useTemplate];
|
|
100
110
|
|
|
101
111
|
if (0 < this.templatePropertyKeys[set.useTemplate].length) {
|
|
@@ -104,9 +114,10 @@ export class DynamoNTS_EmailService {
|
|
|
104
114
|
this.templatePropertyKeys[set.useTemplate].forEach((key: string, index: number) => {
|
|
105
115
|
props += `${key}${index != this.templatePropertyKeys[set.useTemplate].length - 1 ? ', ' : ''}`;
|
|
106
116
|
});
|
|
107
|
-
|
|
117
|
+
Dynamo_Log.logError('\nDynamoBEEmailService ERROR: INVALID sendEmail settings', set);
|
|
118
|
+
|
|
108
119
|
throw new Dynamo_Error({
|
|
109
|
-
errorCode: 'NTS-ES4-
|
|
120
|
+
errorCode: 'NTS-ES4-103',
|
|
110
121
|
addECToUserMsg: true,
|
|
111
122
|
message: `TemplateProperties missing! properties needed: ${props}`,
|
|
112
123
|
userMessage: this.defaultErrorUserMsg
|
|
@@ -114,19 +125,12 @@ export class DynamoNTS_EmailService {
|
|
|
114
125
|
}
|
|
115
126
|
this.templatePropertyKeys[set.useTemplate].forEach((propertyKey: string) => {
|
|
116
127
|
if (!set.templateProperties[propertyKey]) {
|
|
117
|
-
|
|
128
|
+
Dynamo_Log.logError(`TemplateProperty missing! (${propertyKey})`);
|
|
118
129
|
}
|
|
119
130
|
const reg = new RegExp(`{{${propertyKey}}}`, 'g')
|
|
120
131
|
content = content.replace(reg, set.templateProperties[propertyKey]);
|
|
121
132
|
});
|
|
122
133
|
}
|
|
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
134
|
}
|
|
131
135
|
|
|
132
136
|
let mailOptions: MailOptions = {
|
|
@@ -148,8 +152,13 @@ export class DynamoNTS_EmailService {
|
|
|
148
152
|
});
|
|
149
153
|
});
|
|
150
154
|
} catch (error) {
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
throw new Dynamo_Error({
|
|
156
|
+
errorCode: 'NTS-ES4-100',
|
|
157
|
+
addECToUserMsg: true,
|
|
158
|
+
message: `SendEmail failed!`,
|
|
159
|
+
userMessage: this.defaultErrorUserMsg,
|
|
160
|
+
error
|
|
161
|
+
});
|
|
153
162
|
}
|
|
154
163
|
}
|
|
155
164
|
|
|
@@ -167,7 +176,7 @@ export class DynamoNTS_EmailService {
|
|
|
167
176
|
templatePath = Path.join(rootPath, templatePath);
|
|
168
177
|
FileSystem.readFile(templatePath, 'utf8' , (err, template) => {
|
|
169
178
|
if (err) {
|
|
170
|
-
|
|
179
|
+
Dynamo_Log.logError(`\nDynamoBEEmailService readFile ERROR (0), Couldn't load email template; ${templateName} from ${templatePath}\nerror:\n`, err, '\n');
|
|
171
180
|
reject(err);
|
|
172
181
|
return;
|
|
173
182
|
} else {
|
|
@@ -183,7 +192,7 @@ export class DynamoNTS_EmailService {
|
|
|
183
192
|
});
|
|
184
193
|
});
|
|
185
194
|
} catch (error) {
|
|
186
|
-
|
|
195
|
+
Dynamo_Log.logError(`\nDynamoBEEmailService ERROR (1), Couldn't load email template; ${templateName} from ${templatePath}`, new Error());
|
|
187
196
|
}
|
|
188
197
|
}
|
|
189
198
|
|
|
@@ -197,9 +206,10 @@ export class DynamoNTS_EmailService {
|
|
|
197
206
|
const propertyKeys: string[] = [];
|
|
198
207
|
let propertyOpenTagIndex = template.indexOf('{{');
|
|
199
208
|
let propertyCloseTagIndex = template.indexOf('}}', propertyOpenTagIndex + 2);
|
|
209
|
+
|
|
200
210
|
while (propertyOpenTagIndex >= 0) {
|
|
201
211
|
if (propertyCloseTagIndex === -1) {
|
|
202
|
-
|
|
212
|
+
Dynamo_Log.logError(`\nDynamoBEEmailService ERROR, missing closing tag from email template! (${propertyOpenTagIndex} -)`, propertyKeys);
|
|
203
213
|
throw new Dynamo_Error({
|
|
204
214
|
errorCode: 'NTS-ES4-200',
|
|
205
215
|
addECToUserMsg: true,
|
|
@@ -207,17 +217,19 @@ export class DynamoNTS_EmailService {
|
|
|
207
217
|
userMessage: this.defaultErrorUserMsg
|
|
208
218
|
});
|
|
209
219
|
}
|
|
220
|
+
|
|
210
221
|
const newKey: string = template.substring(propertyOpenTagIndex + 2, propertyCloseTagIndex);
|
|
211
222
|
if (!propertyKeys.includes(newKey)) {
|
|
212
223
|
propertyKeys.push(newKey);
|
|
213
224
|
}
|
|
225
|
+
|
|
214
226
|
propertyOpenTagIndex = template.indexOf('{{', propertyOpenTagIndex + 2);
|
|
215
227
|
propertyCloseTagIndex = template.indexOf('}}', propertyOpenTagIndex + 2);
|
|
216
228
|
}
|
|
217
229
|
// console.log('\n\n\nTEST propertyKeys: ', propertyKeys);
|
|
218
230
|
return propertyKeys;
|
|
219
231
|
} catch (error) {
|
|
220
|
-
|
|
232
|
+
Dynamo_Log.logError(`\nDynamoBEEmailService ERROR, getTemplatePropertyKeys ERROR`, new Error(), '\ntemplate:\n', template);
|
|
221
233
|
}
|
|
222
234
|
}
|
|
223
235
|
}
|
|
@@ -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
|
/**
|
|
@@ -65,7 +64,9 @@ export class DynamoNTS_RoutingModule {
|
|
|
65
64
|
|
|
66
65
|
protected log: boolean = dynamoNTS_GlobalSettings.logSetup;
|
|
67
66
|
|
|
68
|
-
defaultErrorUserMsg =
|
|
67
|
+
defaultErrorUserMsg =
|
|
68
|
+
`We encountered an uncought BackEnd Build Error, ` +
|
|
69
|
+
`\nplease contact the responsible development team.`;
|
|
69
70
|
|
|
70
71
|
constructor(
|
|
71
72
|
set: DynamoNTS_RoutingModuleSettings
|
|
@@ -78,7 +79,7 @@ export class DynamoNTS_RoutingModule {
|
|
|
78
79
|
|
|
79
80
|
if (this.log) console.log(`routing module setup done: ${this.route} serurity: ${this.security}\n`);
|
|
80
81
|
} catch (error) {
|
|
81
|
-
|
|
82
|
+
Dynamo_Log.logError(`Routing module setup failed (${this.route})`, error);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
|