@futdevpro/nts-dynamo 1.7.1 → 1.7.4

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.
Files changed (64) hide show
  1. package/.copilot/patterns.json +8 -0
  2. package/lib/_constants/mocks/socket-server.mock.d.ts.map +1 -1
  3. package/lib/_constants/mocks/socket-server.mock.js +4 -1
  4. package/lib/_constants/mocks/socket-server.mock.js.map +1 -1
  5. package/lib/_models/control-models/endpoint-params.control-model.d.ts.map +1 -1
  6. package/lib/_models/control-models/endpoint-params.control-model.js +3 -22
  7. package/lib/_models/control-models/endpoint-params.control-model.js.map +1 -1
  8. package/lib/_models/control-models/socket-presence.control-model.d.ts +5 -3
  9. package/lib/_models/control-models/socket-presence.control-model.d.ts.map +1 -1
  10. package/lib/_models/control-models/socket-presence.control-model.js +34 -20
  11. package/lib/_models/control-models/socket-presence.control-model.js.map +1 -1
  12. package/lib/_models/interfaces/global-service-settings.interface.d.ts +11 -0
  13. package/lib/_models/interfaces/global-service-settings.interface.d.ts.map +1 -1
  14. package/lib/_models/interfaces/port-settings.interface.d.ts +7 -1
  15. package/lib/_models/interfaces/port-settings.interface.d.ts.map +1 -1
  16. package/lib/_models/interfaces/port-settings.interface.js +23 -0
  17. package/lib/_models/interfaces/port-settings.interface.js.map +1 -1
  18. package/lib/_modules/usage/usage.controller.d.ts.map +1 -1
  19. package/lib/_modules/usage/usage.controller.js +0 -1
  20. package/lib/_modules/usage/usage.controller.js.map +1 -1
  21. package/lib/_services/base/data.service.d.ts +1 -1
  22. package/lib/_services/base/data.service.d.ts.map +1 -1
  23. package/lib/_services/base/data.service.js +5 -4
  24. package/lib/_services/base/data.service.js.map +1 -1
  25. package/lib/_services/core/api.service.d.ts +1 -0
  26. package/lib/_services/core/api.service.d.ts.map +1 -1
  27. package/lib/_services/core/api.service.js +19 -21
  28. package/lib/_services/core/api.service.js.map +1 -1
  29. package/lib/_services/core/email.service.js +1 -1
  30. package/lib/_services/core/email.service.js.map +1 -1
  31. package/lib/_services/core/global.service.d.ts +1 -3
  32. package/lib/_services/core/global.service.d.ts.map +1 -1
  33. package/lib/_services/core/global.service.js +2 -7
  34. package/lib/_services/core/global.service.js.map +1 -1
  35. package/lib/_services/server/app-extended.server.d.ts +2 -2
  36. package/lib/_services/server/app-extended.server.d.ts.map +1 -1
  37. package/lib/_services/server/app-extended.server.js +12 -10
  38. package/lib/_services/server/app-extended.server.js.map +1 -1
  39. package/lib/_services/server/app.server.d.ts +4 -40
  40. package/lib/_services/server/app.server.d.ts.map +1 -1
  41. package/lib/_services/server/app.server.js +61 -35
  42. package/lib/_services/server/app.server.js.map +1 -1
  43. package/lib/_services/socket/socket-client.service.js +4 -4
  44. package/lib/_services/socket/socket-server.service.d.ts +3 -3
  45. package/lib/_services/socket/socket-server.service.d.ts.map +1 -1
  46. package/lib/_services/socket/socket-server.service.js +15 -14
  47. package/lib/_services/socket/socket-server.service.js.map +1 -1
  48. package/lib/tsconfig.tsbuildinfo +1 -1
  49. package/nodemon.json +1 -1
  50. package/package.json +13 -13
  51. package/src/_constants/mocks/socket-server.mock.ts +4 -1
  52. package/src/_models/control-models/endpoint-params.control-model.ts +8 -24
  53. package/src/_models/control-models/socket-presence.control-model.ts +70 -21
  54. package/src/_models/interfaces/global-service-settings.interface.ts +11 -0
  55. package/src/_models/interfaces/port-settings.interface.ts +25 -3
  56. package/src/_modules/usage/usage.controller.ts +0 -1
  57. package/src/_services/base/data.service.ts +8 -5
  58. package/src/_services/core/api.service.ts +36 -21
  59. package/src/_services/core/email.service.ts +1 -1
  60. package/src/_services/core/global.service.ts +3 -9
  61. package/src/_services/server/app-extended.server.ts +18 -10
  62. package/src/_services/server/app.server.ts +127 -80
  63. package/src/_services/socket/socket-client.service.ts +4 -4
  64. package/src/_services/socket/socket-server.service.ts +17 -14
@@ -7,7 +7,7 @@ import * as Https from 'https';
7
7
  import * as FileSystem from 'fs';
8
8
  import * as BodyParser from 'body-parser';
9
9
 
10
- import { Request, Response } from 'express';
10
+ import { ErrorRequestHandler } from 'express';
11
11
 
12
12
  import { Dynamo_Array, Dynamo_Error, dynamo_error_default, Dynamo_Log, second, wait } from '@futdevpro/fsm-dynamo';
13
13
 
@@ -24,7 +24,6 @@ import { DynamoNTS_EndpointParams } from '../../_models/control-models/endpoint-
24
24
  import { DynamoNTS_AppSystemControls } from '../../_models/control-models/app-system-controls.control-model';
25
25
 
26
26
 
27
-
28
27
  /**
29
28
  * This will be the MAIN service of our server project,
30
29
  * follow the types and type instructions while setting up your project
@@ -198,8 +197,8 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
198
197
  private _security: DynamoNTS_RouteSecurity;
199
198
  protected get security(): DynamoNTS_RouteSecurity { return this._security; }
200
199
 
201
- protected _ports: DynamoNTS_PortSettings;
202
- protected get ports(): DynamoNTS_PortSettings { return this._ports; }
200
+ protected _portSettings: DynamoNTS_PortSettings;
201
+ protected get ports(): DynamoNTS_PortSettings { return this._portSettings; }
203
202
 
204
203
  private _cert?: DynamoNTS_CertificationSettings;
205
204
  protected get cert(): DynamoNTS_CertificationSettings { return this._cert; }
@@ -214,6 +213,11 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
214
213
 
215
214
  private _routingModules: DynamoNTS_RoutingModule[] = [];
216
215
 
216
+ defaultErrorUserMsg =
217
+ `We encountered a Server Error, ` +
218
+ `\nplease contact the responsible development team.\n` +
219
+ `\n(Internal Server error)`;
220
+
217
221
  /**
218
222
  * setting this value to true, enables this service debug logs
219
223
  */
@@ -245,7 +249,10 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
245
249
  });
246
250
 
247
251
  this.asyncConstruct(extended).catch((error: any) => {
248
- Dynamo_Log.error(`\nApplication: ${this._params.name} start failed.\n`, error);
252
+ Dynamo_Log.error(
253
+ `\nApplication: ${this._params.name} start failed.` +
254
+ `\n`, error
255
+ );
249
256
  });
250
257
  }
251
258
 
@@ -253,21 +260,20 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
253
260
  if (this.logFn && this.deepLog) console.log('\nfn:. asyncConstruct');
254
261
  try {
255
262
  this.systemControls.app.init = true;
256
- this._params = this.getAppParams();
263
+ this._params = this.getAppParams();
257
264
 
258
- dynamo_error_default.issuerSystem = this._params.systemName;
265
+ dynamo_error_default.issuerSystem = this._params.systemName;
259
266
 
260
- this.overrideDynamoNTSGlobalSettings?.();
267
+ this.overrideDynamoNTSGlobalSettings?.();
261
268
 
262
269
  this.logSetup = dynamoNTS_globalSettings.logSetup;
263
270
 
264
271
  this.globalService = DynamoNTS_GlobalService.getInstance();
265
272
  DynamoNTS_GlobalService.setServices(this.getGlobalServiceCollection());
266
273
  DynamoNTS_GlobalService.setParams(this.params);
267
- DynamoNTS_GlobalService.setGlobalErrorHandler(this.getGlobalErrorHandler?.());
268
274
 
269
275
  if (this.getPortSettings) {
270
- this._ports = this.getPortSettings();
276
+ this._portSettings = this.getPortSettings();
271
277
  }
272
278
 
273
279
  if (this.getCertificationSettings) {
@@ -322,8 +328,12 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
322
328
  this.constructErrors.push(error);
323
329
  Dynamo_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
324
330
  throw new Dynamo_Error({
331
+ ...this._getDefaultErrorSettings(
332
+ 'asyncConstruct',
333
+ error
334
+ ),
335
+
325
336
  errorCode: 'NTS-AS0-001',
326
- error: error,
327
337
  additionalContent: {
328
338
  constructErrors: this.constructErrors,
329
339
  systemControls: this.systemControls,
@@ -346,7 +356,12 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
346
356
  if (this.constructErrors.length) {
347
357
  Dynamo_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
348
358
  throw new Dynamo_Error({
349
- message: `${this._params.name} start failed. ERRORS`,
359
+ ...this._getDefaultErrorSettings(
360
+ 'ready',
361
+ new Error(`${this._params.name} start failed. ERRORS`)
362
+ ),
363
+
364
+ errorCode: 'NTS-AS0-R1',
350
365
  additionalContent: this.constructErrors.length === 1 ? this.constructErrors[0] : { errors: this.constructErrors },
351
366
  });
352
367
  }
@@ -370,7 +385,12 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
370
385
  if (timeout < +new Date() - start) {
371
386
  Dynamo_Log.error(`${this._params.name} start failed. TIMEOUT`, this.constructErrors);
372
387
  throw new Dynamo_Error({
373
- message: `${this._params.name} start failed. TIMEOUT`,
388
+ ...this._getDefaultErrorSettings(
389
+ 'ready',
390
+ new Error(`${this._params.name} start failed. TIMEOUT`)
391
+ ),
392
+
393
+ errorCode: 'NTS-AS0-R2',
374
394
  additionalContent: {
375
395
  constructErrors: this.constructErrors,
376
396
  systemControls: this.systemControls,
@@ -386,7 +406,12 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
386
406
  if (this.constructErrors.length) {
387
407
  Dynamo_Log.error(`${this._params.name} start failed. ERROR`, this.constructErrors);
388
408
  throw new Dynamo_Error({
389
- message: `${this._params.name} start failed. ERROR`,
409
+ ...this._getDefaultErrorSettings(
410
+ 'ready',
411
+ new Error(`${this._params.name} start failed. ERROR`)
412
+ ),
413
+
414
+ errorCode: 'NTS-AS0-R3',
390
415
  additionalContent: this.constructErrors,
391
416
  });
392
417
  }
@@ -412,8 +437,12 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
412
437
 
413
438
  Dynamo_Log.error(msg, this.constructErrors);
414
439
  throw new Dynamo_Error({
415
- errorCode: 'NTS-AS0-110',
416
- message: msg,
440
+ ...this._getDefaultErrorSettings(
441
+ 'ready',
442
+ new Error(msg)
443
+ ),
444
+
445
+ errorCode: 'NTS-AS0-R4',
417
446
  additionalContent: {
418
447
  constructErrors: this.constructErrors,
419
448
  systemControls: this.systemControls,
@@ -435,11 +464,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
435
464
 
436
465
  if (this.systemControls.mongoose.init) {
437
466
  this.systemControls.mongoose.started = false;
467
+
438
468
  if (this.mongoose) {
439
469
  await Dynamo_Array.asyncForEach(Object.keys(this.mongoose.models), async (modelName) => {
440
470
  await this.mongoose.deleteModel(modelName);
441
471
  });
442
472
  await this.mongoose.disconnect();
473
+
443
474
  } else {
444
475
  Dynamo_Log.error(`\nMongoose not found.`);
445
476
  }
@@ -491,9 +522,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
491
522
  Dynamo_Log.error('\nUnable to connect to MongoDB server, ERROR: ', error);
492
523
  reject(
493
524
  new Dynamo_Error({
494
- errorCode: 'NTS-AS0-100',
525
+ ...this._getDefaultErrorSettings(
526
+ 'startDB',
527
+ error
528
+ ),
529
+
530
+ errorCode: 'NTS-AS0-SDB1',
495
531
  message: `Unable to connect to MongoDB server, ERROR: ${error}`,
496
- error: error,
497
532
  })
498
533
  );
499
534
  })
@@ -520,7 +555,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
520
555
  private async initExpresses(): Promise<void> {
521
556
  if (this.logFn && this.deepLog) console.log('\nfn:. initExpresses');
522
557
  if (this._security && this._security !== DynamoNTS_RouteSecurity.secure) {
523
- if (!this._ports.httpPort) {
558
+ if (!this._portSettings.httpPort) {
524
559
  let errorMsg: string =
525
560
  `\nYou have open routes, but httpPort is not set!` +
526
561
  `\nsecurity: ${this._security}` +
@@ -551,7 +586,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
551
586
  }
552
587
 
553
588
  if (this._security && this._security !== DynamoNTS_RouteSecurity.open) {
554
- if (!this._cert || !this._ports.httpsPort) {
589
+ if (!this._cert || !this._portSettings.httpsPort) {
555
590
  let errorMsg: string =
556
591
  `\nYou have secure routes, but the certification paths or httpsPort are not set!` +
557
592
  `\nsecurity: ${this._security}` +
@@ -594,8 +629,8 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
594
629
  protected async initOpenExpress(): Promise<void> {
595
630
  if (this.logFn) console.log('\nfn:. initOpenExpress');
596
631
  this.openExpress = Express();
597
- this.openExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
598
- this.openExpress.use(BodyParser.json({ limit: '50mb' }));
632
+ this.openExpress.use(BodyParser.urlencoded(this._portSettings.httpEncodeSettings));
633
+ this.openExpress.use(BodyParser.json(this._portSettings.httpJsonSettings));
599
634
  }
600
635
 
601
636
  /**
@@ -604,8 +639,8 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
604
639
  protected async initSecureExpress(): Promise<void> {
605
640
  if (this.logFn) console.log('\nfn:. initSecureExpress');
606
641
  this.secureExpress = Express();
607
- this.secureExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
608
- this.secureExpress.use(BodyParser.json({ limit: '50mb' }));
642
+ this.secureExpress.use(BodyParser.urlencoded(this._portSettings.httpsEncodeSettings));
643
+ this.secureExpress.use(BodyParser.json(this._portSettings.httpsJsonSettings));
609
644
 
610
645
  const options = {
611
646
  key: FileSystem.readFileSync(this._cert.keyPath),
@@ -624,9 +659,9 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
624
659
  await new Promise<void>((resolve, reject) => {
625
660
  this.systemControls.httpsServer.init = true;
626
661
  this.httpsServer
627
- .listen(this._ports.httpsPort, 'localhost', 0, () => {
662
+ .listen(this._portSettings.httpsPort, 'localhost', 0, () => {
628
663
  this.systemControls.httpsServer.started = true;
629
- Dynamo_Log.success(`\nHTTPS (secure) server is listening on port: ${this._ports.httpsPort}`);
664
+ Dynamo_Log.success(`\nHTTPS (secure) server is listening on port: ${this._portSettings.httpsPort}`);
630
665
  resolve();
631
666
  })
632
667
  .on('error', (error) => {
@@ -635,9 +670,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
635
670
  Dynamo_Log.error(`\nHTTPS (secure) server ERROR`, error);
636
671
  reject(
637
672
  new Dynamo_Error({
638
- errorCode: 'NTS-AS0-001',
673
+ ...this._getDefaultErrorSettings(
674
+ 'startExpresses',
675
+ error
676
+ ),
677
+
678
+ errorCode: 'NTS-AS0-SE1',
639
679
  message: `HTTPS (secure) server ERROR`,
640
- error: error,
641
680
  })
642
681
  );
643
682
  })
@@ -645,9 +684,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
645
684
  Dynamo_Log.warn(
646
685
  `\nHTTPS (secure) server uncaughtException`,
647
686
  new Dynamo_Error({
648
- errorCode: 'NTS-AS0-002',
687
+ ...this._getDefaultErrorSettings(
688
+ 'startExpresses',
689
+ ex
690
+ ),
691
+
692
+ errorCode: 'NTS-AS0-SE2',
649
693
  message: `HTTPS (secure) server uncaughtException`,
650
- error: ex,
651
694
  })
652
695
  );
653
696
  });
@@ -658,9 +701,9 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
658
701
  this.systemControls.httpServer.init = true;
659
702
  await new Promise<void>((resolve, reject) => {
660
703
  this.httpServer = this.openExpress
661
- .listen(this._ports.httpPort, () => {
704
+ .listen(this._portSettings.httpPort, () => {
662
705
  this.systemControls.httpServer.started = true;
663
- Dynamo_Log.success(`\nHTTP (open) server is listening on port: ${this._ports.httpPort}`);
706
+ Dynamo_Log.success(`\nHTTP (open) server is listening on port: ${this._portSettings.httpPort}`);
664
707
  resolve();
665
708
  })
666
709
  .on('error', (error) => {
@@ -670,9 +713,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
670
713
  Dynamo_Log.error(`\nHTTP (open) server ERROR`, error);
671
714
  reject(
672
715
  new Dynamo_Error({
673
- errorCode: 'NTS-AS0-003',
716
+ ...this._getDefaultErrorSettings(
717
+ 'startExpresses',
718
+ error
719
+ ),
720
+
721
+ errorCode: 'NTS-AS0-SE3',
674
722
  message: `HTTP (open) server ERROR`,
675
- error: error,
676
723
  })
677
724
  );
678
725
  })
@@ -680,9 +727,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
680
727
  Dynamo_Log.warn(
681
728
  `\nHTTP (open) server uncaughtException`,
682
729
  new Dynamo_Error({
683
- errorCode: 'NTS-AS0-004',
730
+ ...this._getDefaultErrorSettings(
731
+ 'startExpresses',
732
+ ex
733
+ ),
734
+
735
+ errorCode: 'NTS-AS0-SE4',
684
736
  message: `HTTP (open) server uncaughtException`,
685
- error: ex
686
737
  })
687
738
  );
688
739
  });
@@ -710,16 +761,20 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
710
761
  );
711
762
 
712
763
  if (1 < existingRoutes.length) {
713
- let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
764
+ let error: Error = new Error(`ROUTE DUPLICATION: ${module.route}`);
714
765
  let errorStack: string[] = error.stack.split('\n');
715
766
  errorStack.splice(1, 4);
716
767
  error.stack = errorStack.join('\n');
717
768
 
718
769
  Dynamo_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
719
770
  throw new Dynamo_Error({
720
- errorCode: 'NTS-AS0-005',
771
+ ...this._getDefaultErrorSettings(
772
+ 'mountSecureRoutes',
773
+ error
774
+ ),
775
+
776
+ errorCode: 'NTS-AS0-MSR1',
721
777
  message: `ROUTE DUPLICATION: ${module.route}`,
722
- error: error,
723
778
  });
724
779
  }
725
780
 
@@ -733,6 +788,18 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
733
788
  */
734
789
  private async mountOpenRoutes(): Promise<void> {
735
790
  if (this.logFn && this.deepLog) console.log('\nfn:. mountOpenRoutes');
791
+
792
+ this.openExpress.use((err, req, res, next) => {
793
+ if (err) {
794
+ Dynamo_Log.error('openExpress ERROR', err);
795
+ DynamoNTS_GlobalService.globalErrorHandler?.(err, req, res);
796
+ } else {
797
+ Dynamo_Log.H_error('WTF', err, req, res);
798
+ }
799
+
800
+ next();
801
+ })
802
+
736
803
  await Dynamo_Array.asyncForEach(this._routingModules, async (module: DynamoNTS_RoutingModule) => {
737
804
  if (module.security !== DynamoNTS_RouteSecurity.secure) {
738
805
  if (this.logSetup) {
@@ -744,16 +811,20 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
744
811
  );
745
812
 
746
813
  if (1 < existingRoutes.length) {
747
- let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
814
+ let error: Error = new Error(`ROUTE DUPLICATION: ${module.route}`);
748
815
  let errorStack: string[] = error.stack.split('\n');
749
816
  errorStack.splice(1, 4);
750
817
  error.stack = errorStack.join('\n');
751
818
 
752
819
  Dynamo_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
753
820
  throw new Dynamo_Error({
754
- errorCode: 'NTS-AS0-006',
821
+ ...this._getDefaultErrorSettings(
822
+ 'mountOpenRoutes',
823
+ error
824
+ ),
825
+
826
+ errorCode: 'NTS-AS0-MOR1',
755
827
  message: `ROUTE DUPLICATION: ${module.route}`,
756
- error: error,
757
828
  });
758
829
  }
759
830
 
@@ -770,8 +841,10 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
770
841
  this._routingModules.forEach((module: DynamoNTS_RoutingModule) => {
771
842
  if (!module.security) {
772
843
  Dynamo_Log.warn(`RoutingModule security is not set for ${module.route}\n`);
844
+
773
845
  } else if (!this._security) {
774
846
  this._security = module.security;
847
+
775
848
  } else if (this._security !== module.security) {
776
849
  this._security = DynamoNTS_RouteSecurity.both;
777
850
  }
@@ -789,6 +862,17 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
789
862
  Dynamo_Log.warn(msg);
790
863
  }
791
864
  }
865
+
866
+ private _getDefaultErrorSettings(fnName: string, error: Error | Dynamo_Error) {
867
+ return {
868
+ status: (error as Dynamo_Error)?.___status ?? 500,
869
+ message: (error as Error)?.message ?? `${fnName} was UNSUCCESFUL (NTS)`,
870
+ addECToUserMsg: true,
871
+ userMessage: this.defaultErrorUserMsg,
872
+ issuerService: `${this?.constructor?.name}-DynamoNTS_App`,
873
+ error: error,
874
+ }
875
+ }
792
876
 
793
877
  /**
794
878
  * #OUTDATED
@@ -843,39 +927,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
843
927
  overrideDynamoNTSGlobalSettings?(): void;
844
928
 
845
929
  /**
846
- * #OUTDATED
847
- * You must setup endpoints and required services in this function
848
- *
849
- * @example
850
- * // Setting up Routes
851
- * setupRoutingModules(): void {
852
- * this.httpPort = env.httpPort;
853
- * this.httpsPort = env.httpsPort;
854
- *
855
- * this.cert = {
856
- * keyPath: Path.join(__dirname, './_assets/cert/ucc.key'),
857
- * certPath: Path.join(__dirname, './_assets/cert/ucc.crt'),
858
- * };
859
- *
860
- * this.routingModules = [
861
- * new DynamoBERountingModule({
862
- * route: '/api/account',
863
- * controllers: [
864
- * AccountController.getInstance(),
865
- * PersonalInformationController.getInstance(),
866
- * ...
867
- * ]
868
- * }),
869
- * new DynamoBERountingModule({
870
- * route: '/api/project',
871
- * controllers: [
872
- * ProjectController.getInstance(),
873
- * ProjectExtensionController.getInstance(),
874
- * ]
875
- * }),
876
- * ...
877
- * ];
878
- * }
930
+ * MISSING Description (TODO)
879
931
  */
880
932
  getRoutingModules?(): DynamoNTS_RoutingModule[];
881
933
 
@@ -899,9 +951,4 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
899
951
  */
900
952
  postProcess?(): Promise<void>;
901
953
 
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
954
  }
@@ -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(`< x > socket-client(${this.params.name}) disconnected!`);
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(`<-=-> socket-client(${this.params.name}) subscription successful!`);
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(`---> socket-client(${this.params.name}) ERROR!:`, content);
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(`<-=- outgoing socket-client(${this.params.name}) event: ${eventType}`);
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
- `---> incoming socket(${this.params.name}) event: ${DynamoNTS_SocketEventKey.subscribe};` +
189
+ `--=> incoming socket(${this.params.name}) event: ${DynamoNTS_SocketEventKey.subscribe};` +
190
190
  `\ncontent:`, content
191
191
  );
192
192
  } else {
193
- Dynamo_Log.log(`---> incoming socket(${this.params.name}) event: ${DynamoNTS_SocketEventKey.subscribe}`);
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);
@@ -201,10 +201,13 @@ export abstract class DynamoNTS_SocketServerService<
201
201
  await this.subscriptionEvent.executeEventTasks(content, issuer);
202
202
 
203
203
  socket.emit(DynamoNTS_SocketEventKey.subscriptionSuccessful, 'subscribe was successful', error => {
204
- Dynamo_Log.error(`Emitting subscriptionSuccessful event failed!\nerror:`, error);
204
+ Dynamo_Log.error(
205
+ `Emitting subscriptionSuccessful event failed!` +
206
+ `\nerror:`, error
207
+ );
205
208
  });
206
209
 
207
- Dynamo_Log.success(`<===> socket(${this.params.name}) subscription successfull (${issuer})`);
210
+ Dynamo_Log.success(`<-==> socket(${this.params.name}) subscription successfull (${issuer})`);
208
211
  } catch (error) {
209
212
  Dynamo_Log.error(`Socket Subscription failed: ${this.params.name} (${this.params.port}) will disconnect now...`, error);
210
213
  socket.emit(DynamoNTS_SocketEventKey.error, error);
@@ -343,7 +346,7 @@ export abstract class DynamoNTS_SocketServerService<
343
346
  }
344
347
 
345
348
  socket.disconnect();
346
- Dynamo_Log.info(`<=x=> socket(${this.params.name}) unsubscription successfull (${issuer})`);
349
+ Dynamo_Log.info(`<x==> socket(${this.params.name}) unsubscription successfull (${issuer})`);
347
350
  } catch (error) {
348
351
  throw new Dynamo_Error({
349
352
  ...this._getDefaultErrorSettings(
@@ -394,9 +397,9 @@ export abstract class DynamoNTS_SocketServerService<
394
397
  }
395
398
  }
396
399
 
397
- async emitError(presenceIssuerId: string, error: any): Promise<void> {
400
+ async emitError(presenceIssuerId: string, error: any, issuer: string): Promise<void> {
398
401
  try {
399
- await this.sendEventForId(presenceIssuerId, DynamoNTS_SocketEventKey.error, error);
402
+ await this.sendEventForId(presenceIssuerId, DynamoNTS_SocketEventKey.error, error, issuer);
400
403
  } catch (error) {
401
404
  throw new Dynamo_Error({
402
405
  ...this._getDefaultErrorSettings(
@@ -411,7 +414,7 @@ export abstract class DynamoNTS_SocketServerService<
411
414
  }
412
415
  }
413
416
 
414
- async sendEventForId(id: string, event: string, content: any/* , error?: (err: any) => void */): Promise<void> {
417
+ async sendEventForId(id: string, event: string, content: any, issuer: string): Promise<void> {
415
418
  try {
416
419
  const presence: DynamoNTS_SocketPresence = this.presences.find((pres: DynamoNTS_SocketPresence) => pres.issuerId === id);
417
420
 
@@ -428,12 +431,12 @@ export abstract class DynamoNTS_SocketServerService<
428
431
  });
429
432
  }
430
433
 
431
- presence.emitEvent(event, content);
434
+ presence.emitEvent(event, content, issuer);
432
435
 
433
436
  if (dynamoNTS_globalSettings.logSocketEventContent) {
434
- Dynamo_Log.success(` <--- emitted socket(${this.params.name}) event for presence: ${event}, presenceId: ${id}) \ncontent:`, content);
437
+ Dynamo_Log.success(` <--= emitted socket(${this.params.name}) event for presence: ${event}, presenceId: ${id}) \ncontent:`, content);
435
438
  } else {
436
- Dynamo_Log.success(` <--- emitted socket(${this.params.name}) event for presence: ${event}, presenceId: ${id})`);
439
+ Dynamo_Log.success(` <--= emitted socket(${this.params.name}) event for presence: ${event}, presenceId: ${id})`);
437
440
  }
438
441
  } catch (error) {
439
442
  try {
@@ -478,12 +481,12 @@ export abstract class DynamoNTS_SocketServerService<
478
481
  }
479
482
  }
480
483
 
481
- broadcastEvent(event: string, content: any): void {
484
+ broadcastEvent(event: string, content: any, issuer: string): void {
482
485
  try {
483
- Dynamo_Log.log(` <==-- broadcasting socket(${this.params.name}) event: ${event}`);
486
+ Dynamo_Log.log(` <=-== broadcasting socket(${this.params.name}) event: ${event}`);
484
487
 
485
488
  this.presences.forEach((presence: DynamoNTS_SocketPresence) => {
486
- presence.emitEvent(event, content);
489
+ presence.emitEvent(event, content, issuer);
487
490
  });
488
491
  } catch (error) {
489
492
  Dynamo_Log.error(`socket(${this.params.name}) Event Broadcast (${event}) failed`, error);