@futdevpro/nts-dynamo 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_models/control-models/endpoint-params.control-model.js +1 -1
- package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
- package/lib/_models/interfaces/global-service-settings.interface.d.ts +11 -0
- package/lib/_models/interfaces/global-service-settings.interface.d.ts.map +1 -1
- package/lib/_modules/usage/usage.controller.d.ts.map +1 -1
- package/lib/_modules/usage/usage.controller.js +0 -1
- package/lib/_modules/usage/usage.controller.js.map +1 -1
- package/lib/_services/core/email.service.js +1 -1
- package/lib/_services/core/email.service.js.map +1 -1
- package/lib/_services/core/global.service.d.ts +1 -3
- package/lib/_services/core/global.service.d.ts.map +1 -1
- package/lib/_services/core/global.service.js +2 -7
- package/lib/_services/core/global.service.js.map +1 -1
- package/lib/_services/server/app.server.d.ts +0 -6
- package/lib/_services/server/app.server.d.ts.map +1 -1
- package/lib/_services/server/app.server.js +0 -1
- package/lib/_services/server/app.server.js.map +1 -1
- package/lib/_services/socket/socket-client.service.js +4 -4
- package/lib/_services/socket/socket-server.service.js +7 -7
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/nodemon.json +1 -1
- package/package.json +10 -11
- package/src/_models/control-models/endpoint-params.control-model.ts +2 -2
- package/src/_models/interfaces/global-service-settings.interface.ts +11 -0
- package/src/_modules/usage/usage.controller.ts +0 -1
- package/src/_services/core/email.service.ts +1 -1
- package/src/_services/core/global.service.ts +3 -9
- package/src/_services/server/app.server.ts +0 -6
- package/src/_services/socket/socket-client.service.ts +4 -4
- package/src/_services/socket/socket-server.service.ts +7 -7
package/package.json
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@futdevpro/nts-dynamo",
|
|
3
|
-
"version": "01.07.
|
|
3
|
+
"version": "01.07.02",
|
|
4
4
|
"description": "Dynamic NodeTS (NodeJS-Typescript), MongoDB Backend System Framework by Future Development Program Ltd.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prep": "npm i rimraf nodemon -g",
|
|
7
|
-
|
|
8
7
|
"start": "npm run prep && nodemon",
|
|
9
8
|
|
|
10
|
-
"deploy": "npm run build",
|
|
11
|
-
"build": "npm run build-
|
|
12
|
-
"build-tgz": "npm run build-
|
|
9
|
+
"deploy": "npm run clean && npm run build-all",
|
|
10
|
+
"build": "npm run build-base && jasmine && npm publish",
|
|
11
|
+
"build-tgz": "npm run build-base && jasmine && npm pack && move ./*.tgz ../npm-tgz-collection",
|
|
12
|
+
"build-all": "npm run build-tgz && npm run build",
|
|
13
13
|
|
|
14
14
|
"build-base": "npm i && rimraf ./lib && npx tsc",
|
|
15
|
-
"build
|
|
16
|
-
"build-clean": "npm run clean && npm run build-base",
|
|
15
|
+
"clean-build": "npm run clean && npm run build-base",
|
|
17
16
|
"clean": "npm run prep && rimraf ./lib && rimraf package-lock.json && rimraf ./node_modules",
|
|
18
17
|
|
|
19
|
-
"test": "npm run build-
|
|
20
|
-
"test
|
|
18
|
+
"test": "npm run build-base && jasmine",
|
|
19
|
+
"clean-test": "npm run clean-build && jasmine"
|
|
21
20
|
},
|
|
22
21
|
"main": "./lib/index.js",
|
|
23
22
|
"module": "./lib/index.js",
|
|
@@ -221,8 +220,8 @@
|
|
|
221
220
|
"@types/socket.io-client": "^3.0.0",
|
|
222
221
|
"jasmine": "^5.0.2",
|
|
223
222
|
"jasmine-ts": "^0.4.0",
|
|
223
|
+
"socket.io": "^4.5.2",
|
|
224
224
|
"nodemon": "^3.0.1",
|
|
225
|
-
"rimraf": "^5.0.1"
|
|
226
|
-
"socket.io": "^4.5.2"
|
|
225
|
+
"rimraf": "^5.0.1"
|
|
227
226
|
}
|
|
228
227
|
}
|
|
@@ -250,8 +250,8 @@ export class DynamoNTS_EndpointParams{
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
} catch (error) {
|
|
253
|
-
|
|
254
|
-
`\n\nDYNAMO MULTILEVEL ERROR:DynamoNTS_EndpointParams:error: (${this.name}, ${this.endpoint})` +
|
|
253
|
+
Dynamo_Log.error(
|
|
254
|
+
`\n\nDYNAMO MULTILEVEL ERROR:DynamoNTS_EndpointParams: error: (${this.name}, ${this.endpoint})` +
|
|
255
255
|
`\n(DYNAMO MULTILEVEL ERROR means, that the ERRORHANDLING is ALSO FAILED, and the error message was not sent.)` +
|
|
256
256
|
`\nERROR:`, error, '\n'
|
|
257
257
|
);
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import { Request, Response } from 'express';
|
|
6
|
+
|
|
2
7
|
import { Dynamo_DataParams } from '@futdevpro/fsm-dynamo';
|
|
3
8
|
|
|
4
9
|
import { DynamoNTS_ServiceCollection } from '../../_services/core/service-collection.service';
|
|
5
10
|
import { DynamoNTS_EmailService } from '../../_services/core/email.service';
|
|
6
11
|
import { DynamoNTS_AuthService } from '../../_services/core/auth.service';
|
|
7
12
|
|
|
13
|
+
|
|
8
14
|
export interface DynamoNTS_GlobalServiceSettings {
|
|
9
15
|
/**
|
|
10
16
|
* You need to setup your Own Auth Service extending the DynamoNTS_AuthService class
|
|
@@ -30,5 +36,10 @@ export interface DynamoNTS_GlobalServiceSettings {
|
|
|
30
36
|
* you can setup socket services by passing a DynamoNTS_SocketServiceCollection list at this point
|
|
31
37
|
*/
|
|
32
38
|
/* socketServiceCollection?: DynamoNTS_SocketServiceCollection, */
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* you can setup global error handler by passing a function at this point
|
|
42
|
+
*/
|
|
43
|
+
errorHandler?: (err: any, req?: Request, res?: Response, issuer?: string) => Promise<void>,
|
|
33
44
|
}
|
|
34
45
|
|
|
@@ -75,7 +75,6 @@ export class UsageController extends DynamoNTS_Controller {
|
|
|
75
75
|
name: 'closeSession',
|
|
76
76
|
type: DynamoNTS_HttpCallType.get,
|
|
77
77
|
endpoint: usageModuleSettings.endPoints.closeSession,
|
|
78
|
-
preProcessess: [ this.authService.authTokenPermAccUsageData ],
|
|
79
78
|
tasks: [
|
|
80
79
|
async (req: Request, res: Response, issuer: string) => {
|
|
81
80
|
const usageService = new UsageService({
|
|
@@ -168,7 +168,7 @@ export class DynamoNTS_EmailService {
|
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
170
|
} catch (error) {
|
|
171
|
-
if (error
|
|
171
|
+
if (error?.includes?.('all recipients were rejected')) {
|
|
172
172
|
throw new Dynamo_Error({
|
|
173
173
|
...this._getDefaultErrorSettings('sendEmail', error, issuer),
|
|
174
174
|
|
|
@@ -37,11 +37,8 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
37
37
|
dbServiceCollection: DynamoNTS_ServiceCollection<DynamoNTS_DBService<any>>; // DynamoNTS_DBServiceCollection;
|
|
38
38
|
emailServiceCollection: DynamoNTS_ServiceCollection<DynamoNTS_EmailService>; // DynamoNTS_EmailServiceCollection;
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return this._globalErrorHandler;
|
|
43
|
-
}
|
|
44
|
-
|
|
40
|
+
static globalErrorHandler?: (err: any, req?: Request, res?: Response, issuer?: string) => Promise<void>;
|
|
41
|
+
|
|
45
42
|
/**
|
|
46
43
|
* You need to setup global Services through this function
|
|
47
44
|
*/
|
|
@@ -66,6 +63,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
66
63
|
|
|
67
64
|
this.instance.authService = set.authService;
|
|
68
65
|
this.instance.emailServiceCollection = set.emailServiceCollection;
|
|
66
|
+
DynamoNTS_GlobalService.globalErrorHandler = set.errorHandler;
|
|
69
67
|
} catch (error) {
|
|
70
68
|
Dynamo_Log.error(`Failed to create DynamoNTS_GlobalService.`, error);
|
|
71
69
|
/* error = new Dynamo_Error({
|
|
@@ -80,10 +78,6 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
80
78
|
this._params = params;
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
static setGlobalErrorHandler(handler?: (err: any, req: Request, res: Response, issuer: string) => Promise<void>): void {
|
|
84
|
-
this.instance.globalErrorHandler = handler;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
81
|
/**
|
|
88
82
|
*
|
|
89
83
|
* @returns
|
|
@@ -264,7 +264,6 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
264
264
|
this.globalService = DynamoNTS_GlobalService.getInstance();
|
|
265
265
|
DynamoNTS_GlobalService.setServices(this.getGlobalServiceCollection());
|
|
266
266
|
DynamoNTS_GlobalService.setParams(this.params);
|
|
267
|
-
DynamoNTS_GlobalService.setGlobalErrorHandler(this.getGlobalErrorHandler?.());
|
|
268
267
|
|
|
269
268
|
if (this.getPortSettings) {
|
|
270
269
|
this._ports = this.getPortSettings();
|
|
@@ -899,9 +898,4 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
|
|
|
899
898
|
*/
|
|
900
899
|
postProcess?(): Promise<void>;
|
|
901
900
|
|
|
902
|
-
/**
|
|
903
|
-
* MISSING Description (TODO)
|
|
904
|
-
* only implemented for endpoints and global Unhandled Rejection
|
|
905
|
-
*/
|
|
906
|
-
getGlobalErrorHandler?(): (err: any, req?: Request, res?: Response, issuer?: string) => Promise<void>;
|
|
907
901
|
}
|
|
@@ -43,7 +43,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
43
43
|
tasks: [
|
|
44
44
|
async () => {
|
|
45
45
|
this._connected = false;
|
|
46
|
-
Dynamo_Log.warn(`<
|
|
46
|
+
Dynamo_Log.warn(`<x > socket-client(${this.params.name}) disconnected!`);
|
|
47
47
|
|
|
48
48
|
if (this._params.reconnect) {
|
|
49
49
|
await delay(this._params.reconnectDelay);
|
|
@@ -57,7 +57,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
57
57
|
eventKey: DynamoNTS_SocketEventKey.subscriptionSuccessful,
|
|
58
58
|
tasks: [
|
|
59
59
|
async () => {
|
|
60
|
-
Dynamo_Log.success(
|
|
60
|
+
Dynamo_Log.success(`<=--> socket-client(${this.params.name}) subscription successful!`);
|
|
61
61
|
}
|
|
62
62
|
]
|
|
63
63
|
}),
|
|
@@ -66,7 +66,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
66
66
|
eventKey: DynamoNTS_SocketEventKey.error,
|
|
67
67
|
tasks: [
|
|
68
68
|
async (content: any) => {
|
|
69
|
-
Dynamo_Log.error(
|
|
69
|
+
Dynamo_Log.error(`=--> socket-client(${this.params.name}) ERROR!:`, content);
|
|
70
70
|
}
|
|
71
71
|
]
|
|
72
72
|
}),
|
|
@@ -178,7 +178,7 @@ export abstract class DynamoNTS_SocketClientService extends DynamoNTS_SingletonS
|
|
|
178
178
|
*/
|
|
179
179
|
protected async emitEvent(eventType: string, content: any): Promise<void> {
|
|
180
180
|
try {
|
|
181
|
-
Dynamo_Log.log(
|
|
181
|
+
Dynamo_Log.log(`<=-- outgoing socket-client(${this.params.name}) event: ${eventType}`);
|
|
182
182
|
this.socket.emit(eventType, content);
|
|
183
183
|
} catch (error) {
|
|
184
184
|
Dynamo_Log.error(`socket-client(${this.params.name}) Service Emit Event failed: ${this.params?.name} (${this.params?.port})`, error);
|
|
@@ -186,11 +186,11 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
186
186
|
*/
|
|
187
187
|
if (dynamoNTS_globalSettings.logSocketEventContent) {
|
|
188
188
|
Dynamo_Log.log(
|
|
189
|
-
|
|
189
|
+
`--=> incoming socket(${this.params.name}) event: ${DynamoNTS_SocketEventKey.subscribe};` +
|
|
190
190
|
`\ncontent:`, content
|
|
191
191
|
);
|
|
192
192
|
} else {
|
|
193
|
-
Dynamo_Log.log(
|
|
193
|
+
Dynamo_Log.log(`--=> incoming socket(${this.params.name}) event: ${DynamoNTS_SocketEventKey.subscribe}`);
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
const presence: T_Presence = await this.getPresenceFromSubscrioptionEventContent(content, socket);
|
|
@@ -204,7 +204,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
204
204
|
Dynamo_Log.error(`Emitting subscriptionSuccessful event failed!\nerror:`, error);
|
|
205
205
|
});
|
|
206
206
|
|
|
207
|
-
Dynamo_Log.success(
|
|
207
|
+
Dynamo_Log.success(`<-==> socket(${this.params.name}) subscription successfull (${issuer})`);
|
|
208
208
|
} catch (error) {
|
|
209
209
|
Dynamo_Log.error(`Socket Subscription failed: ${this.params.name} (${this.params.port}) will disconnect now...`, error);
|
|
210
210
|
socket.emit(DynamoNTS_SocketEventKey.error, error);
|
|
@@ -343,7 +343,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
socket.disconnect();
|
|
346
|
-
Dynamo_Log.info(
|
|
346
|
+
Dynamo_Log.info(`<x==> socket(${this.params.name}) unsubscription successfull (${issuer})`);
|
|
347
347
|
} catch (error) {
|
|
348
348
|
throw new Dynamo_Error({
|
|
349
349
|
...this._getDefaultErrorSettings(
|
|
@@ -431,9 +431,9 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
431
431
|
presence.emitEvent(event, content);
|
|
432
432
|
|
|
433
433
|
if (dynamoNTS_globalSettings.logSocketEventContent) {
|
|
434
|
-
Dynamo_Log.success(`
|
|
434
|
+
Dynamo_Log.success(` <--= emitted socket(${this.params.name}) event for presence: ${event}, presenceId: ${id}) \ncontent:`, content);
|
|
435
435
|
} else {
|
|
436
|
-
Dynamo_Log.success(`
|
|
436
|
+
Dynamo_Log.success(` <--= emitted socket(${this.params.name}) event for presence: ${event}, presenceId: ${id})`);
|
|
437
437
|
}
|
|
438
438
|
} catch (error) {
|
|
439
439
|
try {
|
|
@@ -480,7 +480,7 @@ export abstract class DynamoNTS_SocketServerService<
|
|
|
480
480
|
|
|
481
481
|
broadcastEvent(event: string, content: any): void {
|
|
482
482
|
try {
|
|
483
|
-
Dynamo_Log.log(`
|
|
483
|
+
Dynamo_Log.log(` <=-== broadcasting socket(${this.params.name}) event: ${event}`);
|
|
484
484
|
|
|
485
485
|
this.presences.forEach((presence: DynamoNTS_SocketPresence) => {
|
|
486
486
|
presence.emitEvent(event, content);
|