@futdevpro/nts-dynamo 1.5.40 → 1.5.47
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/futdevpro-nts-dynamo-01.05.41.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.42.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.43.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.44.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.45.tgz +0 -0
- package/lib/_enums/http/socket-event.enum.d.ts +2 -0
- package/lib/_enums/http/socket-event.enum.d.ts.map +1 -1
- package/lib/_enums/http/socket-event.enum.js +2 -0
- package/lib/_enums/http/socket-event.enum.js.map +1 -1
- package/lib/_models/dynamo-nts-endpoint-params.js +1 -1
- package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -1
- package/lib/_models/dynamo-nts-socket-dictionary.d.ts +16 -0
- package/lib/_models/dynamo-nts-socket-dictionary.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-socket-dictionary.js +31 -0
- package/lib/_models/dynamo-nts-socket-dictionary.js.map +1 -0
- package/lib/_models/dynamo-nts-socket-event-params.d.ts +2 -0
- package/lib/_models/dynamo-nts-socket-event-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-event-params.js +6 -5
- package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
- package/lib/_models/index.d.ts +1 -0
- package/lib/_models/index.d.ts.map +1 -1
- package/lib/_models/index.js +1 -0
- package/lib/_models/index.js.map +1 -1
- package/lib/_modules/app-extended.index.d.ts +1 -0
- package/lib/_modules/app-extended.index.d.ts.map +1 -1
- package/lib/_modules/app-extended.index.js +1 -0
- package/lib/_modules/app-extended.index.js.map +1 -1
- package/lib/_modules/test/custom-data.service.d.ts +3 -3
- package/lib/_modules/test/custom-data.service.d.ts.map +1 -1
- package/lib/_modules/test/custom-data.service.js +4 -4
- package/lib/_modules/test/custom-data.service.js.map +1 -1
- package/lib/_modules/test/test-controller.js +6 -6
- package/lib/_modules/test/test-controller.js.map +1 -1
- package/lib/_modules/usage/usage-controller.js +1 -1
- package/lib/_modules/usage/usage-controller.js.map +1 -1
- package/lib/_modules/usage/usage.service.d.ts +6 -6
- package/lib/_modules/usage/usage.service.d.ts.map +1 -1
- package/lib/_modules/usage/usage.service.js +18 -10
- package/lib/_modules/usage/usage.service.js.map +1 -1
- package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-api.service.js +19 -8
- package/lib/_services/dynamo-nts-api.service.js.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.d.ts +1 -1
- package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.js +2 -4
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
- package/lib/_services/dynamo-nts-app.d.ts +1 -0
- package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app.js +4 -1
- package/lib/_services/dynamo-nts-app.js.map +1 -1
- package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-auth.service.js +10 -4
- package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
- package/lib/_services/dynamo-nts-controller.service.d.ts +37 -0
- package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-controller.service.js +37 -0
- package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
- package/lib/_services/dynamo-nts-data.service.d.ts +21 -2
- package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-data.service.js +121 -53
- package/lib/_services/dynamo-nts-data.service.js.map +1 -1
- package/lib/_services/dynamo-nts-db.service.d.ts +4 -4
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-db.service.js +148 -84
- 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 +20 -16
- package/lib/_services/dynamo-nts-email.service.js.map +1 -1
- package/lib/_services/dynamo-nts-global.service.d.ts +5 -5
- package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
- 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 +17 -11
- package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.d.ts +6 -0
- package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.js +8 -0
- package/lib/_services/dynamo-nts-shared.service.js.map +1 -1
- package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts +1 -1
- package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.d.ts +6 -9
- package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.js +25 -20
- package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
- package/lib/_services/dynamobe-api.service.js +2 -2
- package/lib/_services/dynamobe-auth.service.js +2 -2
- package/lib/_services/dynamobe-data.service.d.ts +2 -2
- package/lib/_services/dynamobe-data.service.js +15 -15
- package/lib/_services/dynamobe-db.service.d.ts +4 -4
- package/lib/_services/dynamobe-db.service.js +28 -28
- package/lib/_services/dynamobe-email.service.js +4 -4
- package/lib/_services/dynamobe-global.service.d.ts +3 -3
- package/lib/_services/dynamobe-routing-module.service.js +3 -3
- package/lib/tsconfig.tsbuildinfo +1 -5564
- package/package.json +22 -12
- package/src/_enums/http/socket-event.enum.ts +2 -0
- package/src/_models/dynamo-nts-endpoint-params.ts +1 -1
- package/src/_models/dynamo-nts-socket-dictionary.ts +39 -0
- package/src/_models/dynamo-nts-socket-event-params.ts +8 -5
- package/src/_models/index.ts +1 -0
- package/src/_modules/app-extended.index.ts +1 -0
- package/src/_modules/test/custom-data.service.ts +4 -4
- package/src/_modules/test/test-controller.ts +7 -7
- package/src/_modules/usage/usage-controller.ts +2 -2
- package/src/_modules/usage/usage.service.ts +34 -26
- package/src/_services/dynamo-nts-api.service.ts +26 -9
- package/src/_services/dynamo-nts-app-extended.ts +9 -9
- package/src/_services/dynamo-nts-app.ts +2 -2
- package/src/_services/dynamo-nts-auth.service.ts +13 -5
- package/src/_services/dynamo-nts-controller.service.ts +37 -0
- package/src/_services/dynamo-nts-data.service.ts +123 -55
- package/src/_services/dynamo-nts-db.service.ts +181 -87
- package/src/_services/dynamo-nts-email.service.ts +21 -17
- package/src/_services/dynamo-nts-global.service.ts +12 -5
- package/src/_services/dynamo-nts-routing-module.service.ts +16 -10
- package/src/_services/dynamo-nts-shared.service.ts +9 -0
- package/src/_services/dynamo-nts-socket-service-collection.service.ts +1 -1
- package/src/_services/dynamo-nts-socket.service.ts +33 -29
package/package.json
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@futdevpro/nts-dynamo",
|
|
3
|
-
"version": "01.05.
|
|
3
|
+
"version": "01.05.47",
|
|
4
4
|
"description": "Dynamic NodeTS (NodeJS-Typescript), MongoDB Backend System Framework by Future Development Ltd.",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
6
|
+
"build": "npm run inb",
|
|
7
|
+
"inb": "npm i",
|
|
8
|
+
"postinb": "npm run pinb",
|
|
9
|
+
"pinb": "npx tsc",
|
|
10
|
+
"postpinb": "npm publish",
|
|
11
|
+
|
|
12
|
+
"build-tgz": "npm run inbt",
|
|
13
|
+
"inbt": "npm i",
|
|
14
|
+
"postinbt": "npm run pinbt",
|
|
15
|
+
"pinbt": "npx tsc",
|
|
16
|
+
"postbpinbt": "npm pack"
|
|
10
17
|
},
|
|
11
18
|
"main": "./lib/index.js",
|
|
12
19
|
"module": "./lib/index.js",
|
|
@@ -169,7 +176,7 @@
|
|
|
169
176
|
},
|
|
170
177
|
"homepage": "https:/futdevpro.hu/projects/dynamo",
|
|
171
178
|
"peerDependencies": {
|
|
172
|
-
"@futdevpro/fsm-dynamo": "^1.5.
|
|
179
|
+
"@futdevpro/fsm-dynamo": "^1.5.28",
|
|
173
180
|
|
|
174
181
|
"@types/express": "^4.17.7",
|
|
175
182
|
"@types/geoip-lite": "^1.4.1",
|
|
@@ -179,13 +186,16 @@
|
|
|
179
186
|
"geoip-lite": "^1.4.5",
|
|
180
187
|
"mongoose": "^5.13.14",
|
|
181
188
|
"nodemailer": "^6.7.5",
|
|
182
|
-
"rxjs": "^7.4.0"
|
|
183
|
-
|
|
184
|
-
"dependencies": {
|
|
189
|
+
"rxjs": "^7.4.0",
|
|
190
|
+
|
|
185
191
|
"@types/node": "~14.0.27",
|
|
186
|
-
"socket.io": "^4.5.2",
|
|
187
192
|
"ts-node": "~8.10.2",
|
|
188
|
-
"
|
|
189
|
-
|
|
193
|
+
"typescript": "~4.8.3"
|
|
194
|
+
},
|
|
195
|
+
"peerDevDependencies": {
|
|
196
|
+
"tslib": "~2.0.1"
|
|
197
|
+
},
|
|
198
|
+
"devDependencies": {
|
|
199
|
+
"socket.io": "^4.5.2"
|
|
190
200
|
}
|
|
191
201
|
}
|
|
@@ -84,7 +84,7 @@ export class DynamoNTS_EndpointParams{
|
|
|
84
84
|
let inputs = '';
|
|
85
85
|
for(let i = 0; i < this.pathParams.length; i++) {
|
|
86
86
|
inputs += ` ${this.pathParams[i]}: ${req.params[this.pathParams[i]]}`;
|
|
87
|
-
if (i + 1 < this.pathParams.length || req.body && req.body !== {}) {
|
|
87
|
+
if (i + 1 < this.pathParams.length || req.body && `${req.body}` !== '{}') {
|
|
88
88
|
inputs += ',';
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
|
|
3
|
+
import * as SocketIO from 'socket.io';
|
|
4
|
+
|
|
5
|
+
export class DynamoNTS_SocketDictionary {
|
|
6
|
+
issuerId: string;
|
|
7
|
+
sockets: SocketIO.Socket[];
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
set?: {
|
|
11
|
+
issuerId: string,
|
|
12
|
+
sockets: SocketIO.Socket[],
|
|
13
|
+
}
|
|
14
|
+
) {
|
|
15
|
+
this.issuerId = set.issuerId;
|
|
16
|
+
if (!set.sockets.length) {
|
|
17
|
+
throw new Dynamo_Error({
|
|
18
|
+
status: 406,
|
|
19
|
+
errorCode: 'NTS-SD0-C00',
|
|
20
|
+
addECToUserMsg: true,
|
|
21
|
+
message: 'trying to create DynamoNTS_SocketDictionary without a single active socket',
|
|
22
|
+
userMessage: 'We encountered an unhandled Server Error, please contact the responsible development team.'
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
this.sockets = set.sockets;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Emits event on all sockets
|
|
30
|
+
* @param event
|
|
31
|
+
* @param content
|
|
32
|
+
*/
|
|
33
|
+
emitEvent(event: string, content: any) {
|
|
34
|
+
this.sockets.forEach((socket: SocketIO.Socket) => {
|
|
35
|
+
socket.emit(event, content);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
@@ -8,6 +8,7 @@ import { DynamoNTS_SocketEvent } from '../_enums/http/socket-event.enum';
|
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
10
|
export class DynamoNTS_SocketEventParams<T>{
|
|
11
|
+
socketName?: string;
|
|
11
12
|
event: DynamoNTS_SocketEvent | string;
|
|
12
13
|
|
|
13
14
|
preProcessess?: ((content?: T) => Promise<T>)[];
|
|
@@ -18,6 +19,7 @@ export class DynamoNTS_SocketEventParams<T>{
|
|
|
18
19
|
|
|
19
20
|
constructor(
|
|
20
21
|
set: {
|
|
22
|
+
socketName?: string,
|
|
21
23
|
event: DynamoNTS_SocketEvent | string,
|
|
22
24
|
|
|
23
25
|
preProcessess?: ((content?: T) => Promise<T>)[],
|
|
@@ -28,6 +30,7 @@ export class DynamoNTS_SocketEventParams<T>{
|
|
|
28
30
|
}
|
|
29
31
|
) {
|
|
30
32
|
try {
|
|
33
|
+
this.socketName = set.socketName;
|
|
31
34
|
this.event = set.event;
|
|
32
35
|
|
|
33
36
|
this.preProcessess = set.preProcessess ? set.preProcessess : [];
|
|
@@ -47,7 +50,7 @@ export class DynamoNTS_SocketEventParams<T>{
|
|
|
47
50
|
}
|
|
48
51
|
} catch (error) {
|
|
49
52
|
DynamoNTS_Shared.logError(
|
|
50
|
-
`\nSocket Event params setup failed: ${set.event}`, error);
|
|
53
|
+
`\nSocket Event params setup failed (${this.socketName}): ${set.event}`, error);
|
|
51
54
|
throw error;
|
|
52
55
|
}
|
|
53
56
|
}
|
|
@@ -61,14 +64,14 @@ export class DynamoNTS_SocketEventParams<T>{
|
|
|
61
64
|
try {
|
|
62
65
|
if (this.logEvent) {
|
|
63
66
|
if (this.logEventContent) {
|
|
64
|
-
console.log(`==> incoming ${this.
|
|
67
|
+
console.log(`==> incoming ${this.socketName} socket event: ${this.event} content:`, content);
|
|
65
68
|
} else {
|
|
66
|
-
console.log(`==> incoming ${this.
|
|
69
|
+
console.log(`==> incoming ${this.socketName} socket event: ${this.event}...`);
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
return content;
|
|
70
73
|
} catch (error) {
|
|
71
|
-
console.error(
|
|
74
|
+
console.error(`PreLog failed... (socket: ${this.socketName})`, error);
|
|
72
75
|
}
|
|
73
76
|
};
|
|
74
77
|
}
|
|
@@ -88,7 +91,7 @@ export class DynamoNTS_SocketEventParams<T>{
|
|
|
88
91
|
await this.tasks[i](content, issuer);
|
|
89
92
|
}
|
|
90
93
|
} catch (error) {
|
|
91
|
-
console.error(`Socket Event tasks failed to execute.... (${this.event})`, error, 'content:', content);
|
|
94
|
+
console.error(`Socket Event tasks failed to execute on ${this.socketName}.... (${this.event})`, error, 'content:', content);
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
}
|
package/src/_models/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from '../_models/dynamo-nts-app-params';
|
|
|
11
11
|
export * from '../_models/dynamo-nts-endpoint-params';
|
|
12
12
|
export * from '../_models/dynamo-nts-global-settings';
|
|
13
13
|
export * from '../_models/dynamo-nts-routing-module-settings';
|
|
14
|
+
export * from '../_models/dynamo-nts-socket-dictionary';
|
|
14
15
|
|
|
15
16
|
// ENUMS
|
|
16
17
|
export * from '../_enums/dynamo-nts-route-security.enum';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Dynamo_CustomData, customDataModelParams } from '@futdevpro/fsm-dynamo/test-module';
|
|
5
5
|
import { DynamoNTS_DataService } from '../../_services/dynamo-nts-data.service';
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class Dynamo_CustomDataService extends DynamoNTS_DataService<Dynamo_CustomData> {
|
|
8
8
|
|
|
9
9
|
constructor(
|
|
10
|
-
customData?:
|
|
10
|
+
customData?: Dynamo_CustomData,
|
|
11
11
|
issuer?: string,
|
|
12
12
|
) {
|
|
13
13
|
super(
|
|
14
|
-
new
|
|
14
|
+
new Dynamo_CustomData(customData),
|
|
15
15
|
customDataModelParams,
|
|
16
16
|
issuer
|
|
17
17
|
);
|
|
@@ -4,7 +4,7 @@ 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 {
|
|
7
|
+
import { Dynamo_CustomDataService } from './custom-data.service';
|
|
8
8
|
|
|
9
9
|
export class TestController extends DynamoNTS_Controller {
|
|
10
10
|
|
|
@@ -92,12 +92,12 @@ export class TestController extends DynamoNTS_Controller {
|
|
|
92
92
|
|
|
93
93
|
// CUSTOM DATA
|
|
94
94
|
new DynamoNTS_EndpointParams({
|
|
95
|
-
name: '
|
|
95
|
+
name: 'getDynamo_CustomData',
|
|
96
96
|
type: HttpCallType.get,
|
|
97
|
-
endpoint: testModuleSettings.endPoints.
|
|
97
|
+
endpoint: testModuleSettings.endPoints.getDynamo_CustomData,
|
|
98
98
|
tasks: [
|
|
99
99
|
async (req: Request, res: Response) => {
|
|
100
|
-
const customDataService = new
|
|
100
|
+
const customDataService = new Dynamo_CustomDataService({ _id: req.params.customId });
|
|
101
101
|
|
|
102
102
|
await customDataService.getDataById();
|
|
103
103
|
|
|
@@ -112,12 +112,12 @@ export class TestController extends DynamoNTS_Controller {
|
|
|
112
112
|
}),
|
|
113
113
|
|
|
114
114
|
new DynamoNTS_EndpointParams({
|
|
115
|
-
name: '
|
|
115
|
+
name: 'modifyDynamo_CustomData',
|
|
116
116
|
type: HttpCallType.post,
|
|
117
|
-
endpoint: testModuleSettings.endPoints.
|
|
117
|
+
endpoint: testModuleSettings.endPoints.modifyDynamo_CustomData,
|
|
118
118
|
tasks: [
|
|
119
119
|
async (req: Request, res: Response, issuer: string) => {
|
|
120
|
-
const customDataService = new
|
|
120
|
+
const customDataService = new Dynamo_CustomDataService(req.body, issuer);
|
|
121
121
|
|
|
122
122
|
await customDataService.saveData();
|
|
123
123
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
|
-
import { usageModuleSettings,
|
|
3
|
+
import { usageModuleSettings, Dynamo_UsageSession } from '@futdevpro/fsm-dynamo/usage-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_AuthService } from '../../_services/dynamo-nts-auth.service';
|
|
@@ -30,7 +30,7 @@ export class UsageController extends DynamoNTS_Controller {
|
|
|
30
30
|
const authService = DynamoNTS_GlobalService.getAuthService();
|
|
31
31
|
const username = authService.getUsernameFromRequest(req);
|
|
32
32
|
const usageService = new UsageService({
|
|
33
|
-
usageSession: new
|
|
33
|
+
usageSession: new Dynamo_UsageSession({
|
|
34
34
|
sessionStart: new Date(),
|
|
35
35
|
issuer: username,
|
|
36
36
|
}),
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
|
|
2
2
|
import { Request } from 'express';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
|
|
4
|
+
import { Dynamo_UsageSession, usageSessionModelParams, Dynamo_UsageData,
|
|
5
|
+
Dynamo_DailyUsageData } from '@futdevpro/fsm-dynamo/usage-module';
|
|
6
6
|
|
|
7
7
|
import { DynamoNTS_DataService } from '../../_services/dynamo-nts-data.service';
|
|
8
8
|
import { DynamoNTS_Shared } from '../../_services/dynamo-nts-shared.service';
|
|
9
9
|
|
|
10
|
-
export class UsageService extends DynamoNTS_DataService<
|
|
11
|
-
usageData:
|
|
12
|
-
simplifiedDailyUsage:
|
|
10
|
+
export class UsageService extends DynamoNTS_DataService<Dynamo_UsageSession> {
|
|
11
|
+
usageData: Dynamo_UsageData[] = [];
|
|
12
|
+
simplifiedDailyUsage: Dynamo_DailyUsageData[] = [];
|
|
13
13
|
|
|
14
14
|
constructor(
|
|
15
15
|
set?: {
|
|
16
|
-
usageSession?:
|
|
17
|
-
usageData?:
|
|
16
|
+
usageSession?: Dynamo_UsageSession,
|
|
17
|
+
usageData?: Dynamo_UsageData[],
|
|
18
18
|
issuer?: string,
|
|
19
19
|
}
|
|
20
20
|
) {
|
|
21
21
|
super(
|
|
22
|
-
new
|
|
22
|
+
new Dynamo_UsageSession(set?.usageSession),
|
|
23
23
|
usageSessionModelParams,
|
|
24
24
|
set?.issuer
|
|
25
25
|
);
|
|
@@ -33,8 +33,10 @@ export class UsageService extends DynamoNTS_DataService<DynamoUsageSession> {
|
|
|
33
33
|
|
|
34
34
|
/* console.log(`...getLocationDataFromRequest... ip: ${this.data.address}`, this.data.locationData); */
|
|
35
35
|
} catch (error) {
|
|
36
|
-
throw new
|
|
37
|
-
status: 417,
|
|
36
|
+
throw new Dynamo_Error({
|
|
37
|
+
status: 417,
|
|
38
|
+
errorCode: 'NTS-US0-GLD',
|
|
39
|
+
message: 'getLocationDataFromRequest was unsuccessful',
|
|
38
40
|
userMessage: `We were unable to deep analyze your request.`,
|
|
39
41
|
error
|
|
40
42
|
});
|
|
@@ -45,18 +47,18 @@ export class UsageService extends DynamoNTS_DataService<DynamoUsageSession> {
|
|
|
45
47
|
try {
|
|
46
48
|
await this.dataDBService.find({
|
|
47
49
|
sessionStart: { $gte: DynamoNTS_Shared.oneWeekAgo() }
|
|
48
|
-
}).then((res:
|
|
50
|
+
}).then((res: Dynamo_UsageSession[]) => {
|
|
49
51
|
this.dataList = res;
|
|
50
52
|
});
|
|
51
53
|
this.simplifiedDailyUsage = [];
|
|
52
|
-
this.dataList.forEach((session:
|
|
54
|
+
this.dataList.forEach((session: Dynamo_UsageSession) => {
|
|
53
55
|
let dateIndex = this.simplifiedDailyUsage.findIndex(
|
|
54
|
-
(dailyData:
|
|
56
|
+
(dailyData: Dynamo_DailyUsageData) => dailyData.date === session.date
|
|
55
57
|
);
|
|
56
58
|
if (-1 < dateIndex) {
|
|
57
59
|
this.simplifiedDailyUsage[dateIndex].visitations.push(session);
|
|
58
60
|
} else {
|
|
59
|
-
const newUsageSimple = new
|
|
61
|
+
const newUsageSimple = new Dynamo_DailyUsageData({ date: session.date, visitations: [ session ] });
|
|
60
62
|
this.simplifiedDailyUsage.push(newUsageSimple);
|
|
61
63
|
dateIndex = this.simplifiedDailyUsage.length - 1;
|
|
62
64
|
}
|
|
@@ -76,17 +78,19 @@ export class UsageService extends DynamoNTS_DataService<DynamoUsageSession> {
|
|
|
76
78
|
});
|
|
77
79
|
|
|
78
80
|
this.simplifiedDailyUsage.sort(
|
|
79
|
-
(a:
|
|
81
|
+
(a: Dynamo_DailyUsageData, b: Dynamo_DailyUsageData) => +new Date(b.date) - +new Date(a.date)
|
|
80
82
|
);
|
|
81
|
-
this.simplifiedDailyUsage.forEach((daily:
|
|
83
|
+
this.simplifiedDailyUsage.forEach((daily: Dynamo_DailyUsageData) => {
|
|
82
84
|
daily.visitations.sort(
|
|
83
|
-
(a:
|
|
85
|
+
(a: Dynamo_UsageSession, b: Dynamo_UsageSession) => +a.sessionStart - +b.sessionStart
|
|
84
86
|
);
|
|
85
87
|
});
|
|
86
88
|
|
|
87
89
|
} catch (error) {
|
|
88
|
-
throw new
|
|
89
|
-
status: 417,
|
|
90
|
+
throw new Dynamo_Error({
|
|
91
|
+
status: 417,
|
|
92
|
+
errorCode: 'NTS-US0-GLW',
|
|
93
|
+
message: 'getDailyUsage was unsuccessful',
|
|
90
94
|
userMessage: `We've failed to collect last week's usage data.`,
|
|
91
95
|
error
|
|
92
96
|
});
|
|
@@ -98,7 +102,7 @@ export class UsageService extends DynamoNTS_DataService<DynamoUsageSession> {
|
|
|
98
102
|
await this.getDataById();
|
|
99
103
|
this.data.usageData = this.usageData;
|
|
100
104
|
let totalTime = 0;
|
|
101
|
-
this.data.usageData.forEach((data:
|
|
105
|
+
this.data.usageData.forEach((data: Dynamo_UsageData) => {
|
|
102
106
|
totalTime += data.timeSpentOnPage;
|
|
103
107
|
});
|
|
104
108
|
if (!this.data.locationData) {
|
|
@@ -107,8 +111,10 @@ export class UsageService extends DynamoNTS_DataService<DynamoUsageSession> {
|
|
|
107
111
|
this.data.totalSessionTime = totalTime;
|
|
108
112
|
await this.saveData();
|
|
109
113
|
} catch (error) {
|
|
110
|
-
throw new
|
|
111
|
-
status: 417,
|
|
114
|
+
throw new Dynamo_Error({
|
|
115
|
+
status: 417,
|
|
116
|
+
errorCode: 'NTS-US0-UU0',
|
|
117
|
+
message: 'updateSessionData was unsuccessful',
|
|
112
118
|
userMessage: `The attempt to update Usage Data was unsuccessful.`,
|
|
113
119
|
error
|
|
114
120
|
});
|
|
@@ -124,12 +130,14 @@ export class UsageService extends DynamoNTS_DataService<DynamoUsageSession> {
|
|
|
124
130
|
if (!this.data.locationData) {
|
|
125
131
|
this.getLocationDataFromRequest(req);
|
|
126
132
|
}
|
|
127
|
-
this.data.usageData.sort((a:
|
|
133
|
+
this.data.usageData.sort((a: Dynamo_UsageData, b: Dynamo_UsageData) => +a.opened - +b.opened);
|
|
128
134
|
this.data.totalSessionTime = newTotalSessionTime;
|
|
129
135
|
await this.saveData();
|
|
130
136
|
} catch (error) {
|
|
131
|
-
throw new
|
|
132
|
-
status: 417,
|
|
137
|
+
throw new Dynamo_Error({
|
|
138
|
+
status: 417,
|
|
139
|
+
errorCode: 'NTS-US0-CS0',
|
|
140
|
+
message: 'closeSession was unsuccessful',
|
|
133
141
|
userMessage: `The attempt to close Usage Session was unsuccessful.`,
|
|
134
142
|
error
|
|
135
143
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import * as Axios from 'axios';
|
|
3
|
-
import {
|
|
3
|
+
import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
|
|
4
4
|
|
|
5
5
|
import { HttpCallType } from '../_enums/http/http-call-type.enum';
|
|
6
6
|
import { HttpResponseType } from '../_enums/http/http-response-type.enum';
|
|
@@ -138,29 +138,46 @@ export class DynamoNTS_ApiService {
|
|
|
138
138
|
return a as T;
|
|
139
139
|
}
|
|
140
140
|
} catch (error) {
|
|
141
|
-
DynamoNTS_Shared.logError(`\nAPI
|
|
141
|
+
DynamoNTS_Shared.logError(`\nAPI ERROR: ${callParams?.name} failed...` +
|
|
142
142
|
`\n${callParams?.baseUrl}${callParams?.endPoint}`);
|
|
143
|
+
|
|
143
144
|
if (callParams?.httpOptions?.responseType === HttpResponseType.text) {
|
|
144
145
|
error.error = JSON.parse(error.error);
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
+
|
|
148
|
+
if (error?.response?.data?.flag === 'DYNAMO ERROR OBJECT') {
|
|
147
149
|
DynamoNTS_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
|
|
148
|
-
|
|
150
|
+
|
|
151
|
+
throw new Dynamo_Error({
|
|
152
|
+
errorCode: 'NTS-API-002',
|
|
153
|
+
addECToUserMsg: true,
|
|
154
|
+
message: 'API call failed on the other end! error response found...',
|
|
155
|
+
userMessage: `We encountered a BackEnd API Error, please contact the responsible development team.`,
|
|
156
|
+
error: error.response.data
|
|
157
|
+
});
|
|
149
158
|
} else if (error.code === 'ENOTFOUND') {
|
|
150
159
|
DynamoNTS_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL\n\n`, new Error());
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
160
|
+
|
|
161
|
+
throw new Dynamo_Error({
|
|
162
|
+
status: 404,
|
|
163
|
+
errorCode: 'NTS-API-000',
|
|
164
|
+
addECToUserMsg: true,
|
|
165
|
+
message: 'DNS error; address cannot be resolved!',
|
|
166
|
+
userMessage: `We encountered a BackEnd API Error, please contact the responsible development team.`,
|
|
154
167
|
error: error
|
|
155
168
|
});
|
|
156
169
|
} else if (error.config && error.message) {
|
|
157
|
-
|
|
170
|
+
|
|
171
|
+
throw new Dynamo_Error({
|
|
158
172
|
status: +error.message.substring(error.message.length - 4, 3),
|
|
159
|
-
|
|
173
|
+
errorCode: 'NTS-API-003',
|
|
174
|
+
addECToUserMsg: true,
|
|
175
|
+
userMessage: `We encountered a BackEnd API Error, please contact the responsible development team.`,
|
|
160
176
|
error: error
|
|
161
177
|
});
|
|
162
178
|
} else {
|
|
163
179
|
DynamoNTS_Shared.logError(`\n${callParams.name} was UNSUCCESSFUL`, error, '\n\n', new Error());
|
|
180
|
+
|
|
164
181
|
throw error;
|
|
165
182
|
}
|
|
166
183
|
}
|
|
@@ -32,7 +32,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
32
32
|
|
|
33
33
|
private socketSecurity: DynamoNTS_RouteSecurity;
|
|
34
34
|
|
|
35
|
-
protected socketServices: DynamoNTS_SocketService[]
|
|
35
|
+
protected socketServices: DynamoNTS_SocketService<any>[];
|
|
36
36
|
|
|
37
37
|
constructor(){
|
|
38
38
|
super();
|
|
@@ -47,11 +47,11 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
47
47
|
} else {
|
|
48
48
|
DynamoNTS_Shared.logWarning(
|
|
49
49
|
'\nNo socketServices setted up while using Extended Application.',
|
|
50
|
-
'\nYou should use DynamoNTS_App if you don`t need socket services
|
|
50
|
+
'\nYou should use DynamoNTS_App if you don`t need socket services.\n'
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
} catch (error) {
|
|
54
|
-
DynamoNTS_Shared.logError('\nExtended Application start failed.\n', error);
|
|
54
|
+
DynamoNTS_Shared.logError('\nExtended Application start failed.\n', error, '\n');
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -59,8 +59,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
59
59
|
*
|
|
60
60
|
*/
|
|
61
61
|
private setSocketSecurity(): void {
|
|
62
|
-
|
|
63
|
-
this.socketServices.forEach((service: DynamoNTS_SocketService) => {
|
|
62
|
+
this.socketServices.forEach((service: DynamoNTS_SocketService<any>) => {
|
|
64
63
|
if (!this.socketSecurity) {
|
|
65
64
|
this.socketSecurity = DynamoNTS_RouteSecurity[service.security];
|
|
66
65
|
} else if (this.socketSecurity !== DynamoNTS_RouteSecurity.both && this.socketSecurity !== DynamoNTS_RouteSecurity[service.security]) {
|
|
@@ -95,7 +94,7 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
95
94
|
`\nin DynamoBEServer - setupRoutingModules() to enable secure routes.`;
|
|
96
95
|
|
|
97
96
|
errorMsg += '\n\nThe socket services setted to use secure server:';
|
|
98
|
-
this.socketServices.forEach((service: DynamoNTS_SocketService) => {
|
|
97
|
+
this.socketServices.forEach((service: DynamoNTS_SocketService<any>) => {
|
|
99
98
|
if (service.security != DynamoNTS_SocketSecurity.open) {
|
|
100
99
|
errorMsg += `\n ${service.name} (port: ${service.port})`;
|
|
101
100
|
}
|
|
@@ -112,9 +111,10 @@ export abstract class DynamoNTS_AppExtended extends DynamoNTS_App {
|
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
this.socketServices.forEach((service: DynamoNTS_SocketService) => {
|
|
116
|
-
const existingPorts: DynamoNTS_SocketService[] = this.socketServices.filter(
|
|
117
|
-
|
|
114
|
+
this.socketServices.forEach((service: DynamoNTS_SocketService<any>) => {
|
|
115
|
+
const existingPorts: DynamoNTS_SocketService<any>[] = this.socketServices.filter(
|
|
116
|
+
(mod: DynamoNTS_SocketService<any>) => mod.port === service.port
|
|
117
|
+
);
|
|
118
118
|
|
|
119
119
|
if (1 < existingPorts.length || this.httpPort === service.port || this.httpsPort === service.port) {
|
|
120
120
|
let error = new Error(`PORT DUPLICATION: ${service.port}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { NextFunction, Request, Response } from 'express';
|
|
3
|
-
import {
|
|
3
|
+
import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
|
|
4
4
|
|
|
5
5
|
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
6
6
|
|
|
@@ -29,18 +29,26 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
|
|
|
29
29
|
static getTokenFromRequest(req: Request): string {
|
|
30
30
|
const authHeader = req.headers['authorization'];
|
|
31
31
|
if (!authHeader) {
|
|
32
|
-
throw new
|
|
32
|
+
throw new Dynamo_Error({
|
|
33
|
+
status: 401,
|
|
34
|
+
errorCode: 'NTS-AS0-GT0',
|
|
35
|
+
addECToUserMsg: true,
|
|
33
36
|
message: 'AuthHeader missing!',
|
|
34
|
-
userMessage: `We encountered
|
|
37
|
+
userMessage: `We encountered an unhandled BackEnd Auth Error, please contact the responsible development team.`,
|
|
35
38
|
});
|
|
36
39
|
}
|
|
40
|
+
|
|
37
41
|
const token = authHeader.split(' ')[1];
|
|
38
42
|
if (!token) {
|
|
39
|
-
throw new
|
|
43
|
+
throw new Dynamo_Error({
|
|
44
|
+
status: 401,
|
|
45
|
+
errorCode: 'NTS-AS0-GT1',
|
|
46
|
+
addECToUserMsg: true,
|
|
40
47
|
message: 'Token missing!',
|
|
41
|
-
userMessage: `We encountered
|
|
48
|
+
userMessage: `We encountered an unhandled BackEnd Auth Error, please contact the responsible development team.`,
|
|
42
49
|
});
|
|
43
50
|
}
|
|
51
|
+
|
|
44
52
|
return token;
|
|
45
53
|
}
|
|
46
54
|
|
|
@@ -5,7 +5,44 @@ import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
|
5
5
|
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
+
* Basic controller for endpoint handlings
|
|
8
9
|
*
|
|
10
|
+
* @example
|
|
11
|
+
* export class UserMatchStatisticsController extends DynamoNTS_Controller {
|
|
12
|
+
*
|
|
13
|
+
* static getInstance(): UserMatchStatisticsController {
|
|
14
|
+
* return UserMatchStatisticsController.getSingletonInstance();
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* // SERVICES
|
|
18
|
+
* private authService: AuthService;
|
|
19
|
+
*
|
|
20
|
+
* setupEndpoints(): void {
|
|
21
|
+
* this.authService = AuthService.getInstance();
|
|
22
|
+
*
|
|
23
|
+
* this.endpoints = [
|
|
24
|
+
* new DynamoNTS_EndpointParams({
|
|
25
|
+
* name: 'getUserMatchStatistics',
|
|
26
|
+
* type: HttpCallType.get,
|
|
27
|
+
* endpoint: '/get/user-match-statistics/:userId',
|
|
28
|
+
* preProcessess: [ this.authService.authenticateTokenSelf ],
|
|
29
|
+
* tasks: [
|
|
30
|
+
* async (req: Request, res: Response) => {
|
|
31
|
+
* const userMatchStatistics = new UserMatchStatisticsService({
|
|
32
|
+
* data: { userId: req.params.userId }
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* await userMatchStatistics.getDataByDependencyId();
|
|
36
|
+
*
|
|
37
|
+
* res.send(
|
|
38
|
+
* userMatchStatistics.data
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
* ]
|
|
42
|
+
* }),
|
|
43
|
+
* ];
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
9
46
|
*/
|
|
10
47
|
export abstract class DynamoNTS_Controller extends DynamoNTS_SingletonService {
|
|
11
48
|
|