@futdevpro/nts-dynamo 1.7.2 → 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 (46) 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 +2 -21
  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/port-settings.interface.d.ts +7 -1
  13. package/lib/_models/interfaces/port-settings.interface.d.ts.map +1 -1
  14. package/lib/_models/interfaces/port-settings.interface.js +23 -0
  15. package/lib/_models/interfaces/port-settings.interface.js.map +1 -1
  16. package/lib/_services/base/data.service.d.ts +1 -1
  17. package/lib/_services/base/data.service.d.ts.map +1 -1
  18. package/lib/_services/base/data.service.js +5 -4
  19. package/lib/_services/base/data.service.js.map +1 -1
  20. package/lib/_services/core/api.service.d.ts +1 -0
  21. package/lib/_services/core/api.service.d.ts.map +1 -1
  22. package/lib/_services/core/api.service.js +19 -21
  23. package/lib/_services/core/api.service.js.map +1 -1
  24. package/lib/_services/server/app-extended.server.d.ts +2 -2
  25. package/lib/_services/server/app-extended.server.d.ts.map +1 -1
  26. package/lib/_services/server/app-extended.server.js +12 -10
  27. package/lib/_services/server/app-extended.server.js.map +1 -1
  28. package/lib/_services/server/app.server.d.ts +4 -34
  29. package/lib/_services/server/app.server.d.ts.map +1 -1
  30. package/lib/_services/server/app.server.js +61 -34
  31. package/lib/_services/server/app.server.js.map +1 -1
  32. package/lib/_services/socket/socket-server.service.d.ts +3 -3
  33. package/lib/_services/socket/socket-server.service.d.ts.map +1 -1
  34. package/lib/_services/socket/socket-server.service.js +8 -7
  35. package/lib/_services/socket/socket-server.service.js.map +1 -1
  36. package/lib/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +4 -3
  38. package/src/_constants/mocks/socket-server.mock.ts +4 -1
  39. package/src/_models/control-models/endpoint-params.control-model.ts +6 -22
  40. package/src/_models/control-models/socket-presence.control-model.ts +70 -21
  41. package/src/_models/interfaces/port-settings.interface.ts +25 -3
  42. package/src/_services/base/data.service.ts +8 -5
  43. package/src/_services/core/api.service.ts +36 -21
  44. package/src/_services/server/app-extended.server.ts +18 -10
  45. package/src/_services/server/app.server.ts +127 -74
  46. package/src/_services/socket/socket-server.service.ts +10 -7
@@ -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,11 +260,11 @@ 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
 
@@ -266,7 +273,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
266
273
  DynamoNTS_GlobalService.setParams(this.params);
267
274
 
268
275
  if (this.getPortSettings) {
269
- this._ports = this.getPortSettings();
276
+ this._portSettings = this.getPortSettings();
270
277
  }
271
278
 
272
279
  if (this.getCertificationSettings) {
@@ -321,8 +328,12 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
321
328
  this.constructErrors.push(error);
322
329
  Dynamo_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
323
330
  throw new Dynamo_Error({
331
+ ...this._getDefaultErrorSettings(
332
+ 'asyncConstruct',
333
+ error
334
+ ),
335
+
324
336
  errorCode: 'NTS-AS0-001',
325
- error: error,
326
337
  additionalContent: {
327
338
  constructErrors: this.constructErrors,
328
339
  systemControls: this.systemControls,
@@ -345,7 +356,12 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
345
356
  if (this.constructErrors.length) {
346
357
  Dynamo_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
347
358
  throw new Dynamo_Error({
348
- 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',
349
365
  additionalContent: this.constructErrors.length === 1 ? this.constructErrors[0] : { errors: this.constructErrors },
350
366
  });
351
367
  }
@@ -369,7 +385,12 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
369
385
  if (timeout < +new Date() - start) {
370
386
  Dynamo_Log.error(`${this._params.name} start failed. TIMEOUT`, this.constructErrors);
371
387
  throw new Dynamo_Error({
372
- 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',
373
394
  additionalContent: {
374
395
  constructErrors: this.constructErrors,
375
396
  systemControls: this.systemControls,
@@ -385,7 +406,12 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
385
406
  if (this.constructErrors.length) {
386
407
  Dynamo_Log.error(`${this._params.name} start failed. ERROR`, this.constructErrors);
387
408
  throw new Dynamo_Error({
388
- 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',
389
415
  additionalContent: this.constructErrors,
390
416
  });
391
417
  }
@@ -411,8 +437,12 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
411
437
 
412
438
  Dynamo_Log.error(msg, this.constructErrors);
413
439
  throw new Dynamo_Error({
414
- errorCode: 'NTS-AS0-110',
415
- message: msg,
440
+ ...this._getDefaultErrorSettings(
441
+ 'ready',
442
+ new Error(msg)
443
+ ),
444
+
445
+ errorCode: 'NTS-AS0-R4',
416
446
  additionalContent: {
417
447
  constructErrors: this.constructErrors,
418
448
  systemControls: this.systemControls,
@@ -434,11 +464,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
434
464
 
435
465
  if (this.systemControls.mongoose.init) {
436
466
  this.systemControls.mongoose.started = false;
467
+
437
468
  if (this.mongoose) {
438
469
  await Dynamo_Array.asyncForEach(Object.keys(this.mongoose.models), async (modelName) => {
439
470
  await this.mongoose.deleteModel(modelName);
440
471
  });
441
472
  await this.mongoose.disconnect();
473
+
442
474
  } else {
443
475
  Dynamo_Log.error(`\nMongoose not found.`);
444
476
  }
@@ -490,9 +522,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
490
522
  Dynamo_Log.error('\nUnable to connect to MongoDB server, ERROR: ', error);
491
523
  reject(
492
524
  new Dynamo_Error({
493
- errorCode: 'NTS-AS0-100',
525
+ ...this._getDefaultErrorSettings(
526
+ 'startDB',
527
+ error
528
+ ),
529
+
530
+ errorCode: 'NTS-AS0-SDB1',
494
531
  message: `Unable to connect to MongoDB server, ERROR: ${error}`,
495
- error: error,
496
532
  })
497
533
  );
498
534
  })
@@ -519,7 +555,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
519
555
  private async initExpresses(): Promise<void> {
520
556
  if (this.logFn && this.deepLog) console.log('\nfn:. initExpresses');
521
557
  if (this._security && this._security !== DynamoNTS_RouteSecurity.secure) {
522
- if (!this._ports.httpPort) {
558
+ if (!this._portSettings.httpPort) {
523
559
  let errorMsg: string =
524
560
  `\nYou have open routes, but httpPort is not set!` +
525
561
  `\nsecurity: ${this._security}` +
@@ -550,7 +586,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
550
586
  }
551
587
 
552
588
  if (this._security && this._security !== DynamoNTS_RouteSecurity.open) {
553
- if (!this._cert || !this._ports.httpsPort) {
589
+ if (!this._cert || !this._portSettings.httpsPort) {
554
590
  let errorMsg: string =
555
591
  `\nYou have secure routes, but the certification paths or httpsPort are not set!` +
556
592
  `\nsecurity: ${this._security}` +
@@ -593,8 +629,8 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
593
629
  protected async initOpenExpress(): Promise<void> {
594
630
  if (this.logFn) console.log('\nfn:. initOpenExpress');
595
631
  this.openExpress = Express();
596
- this.openExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
597
- 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));
598
634
  }
599
635
 
600
636
  /**
@@ -603,8 +639,8 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
603
639
  protected async initSecureExpress(): Promise<void> {
604
640
  if (this.logFn) console.log('\nfn:. initSecureExpress');
605
641
  this.secureExpress = Express();
606
- this.secureExpress.use(BodyParser.urlencoded({ limit: '50mb', extended: true }));
607
- 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));
608
644
 
609
645
  const options = {
610
646
  key: FileSystem.readFileSync(this._cert.keyPath),
@@ -623,9 +659,9 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
623
659
  await new Promise<void>((resolve, reject) => {
624
660
  this.systemControls.httpsServer.init = true;
625
661
  this.httpsServer
626
- .listen(this._ports.httpsPort, 'localhost', 0, () => {
662
+ .listen(this._portSettings.httpsPort, 'localhost', 0, () => {
627
663
  this.systemControls.httpsServer.started = true;
628
- 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}`);
629
665
  resolve();
630
666
  })
631
667
  .on('error', (error) => {
@@ -634,9 +670,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
634
670
  Dynamo_Log.error(`\nHTTPS (secure) server ERROR`, error);
635
671
  reject(
636
672
  new Dynamo_Error({
637
- errorCode: 'NTS-AS0-001',
673
+ ...this._getDefaultErrorSettings(
674
+ 'startExpresses',
675
+ error
676
+ ),
677
+
678
+ errorCode: 'NTS-AS0-SE1',
638
679
  message: `HTTPS (secure) server ERROR`,
639
- error: error,
640
680
  })
641
681
  );
642
682
  })
@@ -644,9 +684,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
644
684
  Dynamo_Log.warn(
645
685
  `\nHTTPS (secure) server uncaughtException`,
646
686
  new Dynamo_Error({
647
- errorCode: 'NTS-AS0-002',
687
+ ...this._getDefaultErrorSettings(
688
+ 'startExpresses',
689
+ ex
690
+ ),
691
+
692
+ errorCode: 'NTS-AS0-SE2',
648
693
  message: `HTTPS (secure) server uncaughtException`,
649
- error: ex,
650
694
  })
651
695
  );
652
696
  });
@@ -657,9 +701,9 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
657
701
  this.systemControls.httpServer.init = true;
658
702
  await new Promise<void>((resolve, reject) => {
659
703
  this.httpServer = this.openExpress
660
- .listen(this._ports.httpPort, () => {
704
+ .listen(this._portSettings.httpPort, () => {
661
705
  this.systemControls.httpServer.started = true;
662
- 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}`);
663
707
  resolve();
664
708
  })
665
709
  .on('error', (error) => {
@@ -669,9 +713,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
669
713
  Dynamo_Log.error(`\nHTTP (open) server ERROR`, error);
670
714
  reject(
671
715
  new Dynamo_Error({
672
- errorCode: 'NTS-AS0-003',
716
+ ...this._getDefaultErrorSettings(
717
+ 'startExpresses',
718
+ error
719
+ ),
720
+
721
+ errorCode: 'NTS-AS0-SE3',
673
722
  message: `HTTP (open) server ERROR`,
674
- error: error,
675
723
  })
676
724
  );
677
725
  })
@@ -679,9 +727,13 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
679
727
  Dynamo_Log.warn(
680
728
  `\nHTTP (open) server uncaughtException`,
681
729
  new Dynamo_Error({
682
- errorCode: 'NTS-AS0-004',
730
+ ...this._getDefaultErrorSettings(
731
+ 'startExpresses',
732
+ ex
733
+ ),
734
+
735
+ errorCode: 'NTS-AS0-SE4',
683
736
  message: `HTTP (open) server uncaughtException`,
684
- error: ex
685
737
  })
686
738
  );
687
739
  });
@@ -709,16 +761,20 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
709
761
  );
710
762
 
711
763
  if (1 < existingRoutes.length) {
712
- let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
764
+ let error: Error = new Error(`ROUTE DUPLICATION: ${module.route}`);
713
765
  let errorStack: string[] = error.stack.split('\n');
714
766
  errorStack.splice(1, 4);
715
767
  error.stack = errorStack.join('\n');
716
768
 
717
769
  Dynamo_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
718
770
  throw new Dynamo_Error({
719
- errorCode: 'NTS-AS0-005',
771
+ ...this._getDefaultErrorSettings(
772
+ 'mountSecureRoutes',
773
+ error
774
+ ),
775
+
776
+ errorCode: 'NTS-AS0-MSR1',
720
777
  message: `ROUTE DUPLICATION: ${module.route}`,
721
- error: error,
722
778
  });
723
779
  }
724
780
 
@@ -732,6 +788,18 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
732
788
  */
733
789
  private async mountOpenRoutes(): Promise<void> {
734
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
+
735
803
  await Dynamo_Array.asyncForEach(this._routingModules, async (module: DynamoNTS_RoutingModule) => {
736
804
  if (module.security !== DynamoNTS_RouteSecurity.secure) {
737
805
  if (this.logSetup) {
@@ -743,16 +811,20 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
743
811
  );
744
812
 
745
813
  if (1 < existingRoutes.length) {
746
- let error = new Error(`ROUTE DUPLICATION: ${module.route}`);
814
+ let error: Error = new Error(`ROUTE DUPLICATION: ${module.route}`);
747
815
  let errorStack: string[] = error.stack.split('\n');
748
816
  errorStack.splice(1, 4);
749
817
  error.stack = errorStack.join('\n');
750
818
 
751
819
  Dynamo_Log.error(`ROUTE DUPLICATION: ${module.route}`, error);
752
820
  throw new Dynamo_Error({
753
- errorCode: 'NTS-AS0-006',
821
+ ...this._getDefaultErrorSettings(
822
+ 'mountOpenRoutes',
823
+ error
824
+ ),
825
+
826
+ errorCode: 'NTS-AS0-MOR1',
754
827
  message: `ROUTE DUPLICATION: ${module.route}`,
755
- error: error,
756
828
  });
757
829
  }
758
830
 
@@ -769,8 +841,10 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
769
841
  this._routingModules.forEach((module: DynamoNTS_RoutingModule) => {
770
842
  if (!module.security) {
771
843
  Dynamo_Log.warn(`RoutingModule security is not set for ${module.route}\n`);
844
+
772
845
  } else if (!this._security) {
773
846
  this._security = module.security;
847
+
774
848
  } else if (this._security !== module.security) {
775
849
  this._security = DynamoNTS_RouteSecurity.both;
776
850
  }
@@ -788,6 +862,17 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
788
862
  Dynamo_Log.warn(msg);
789
863
  }
790
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
+ }
791
876
 
792
877
  /**
793
878
  * #OUTDATED
@@ -842,39 +927,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
842
927
  overrideDynamoNTSGlobalSettings?(): void;
843
928
 
844
929
  /**
845
- * #OUTDATED
846
- * You must setup endpoints and required services in this function
847
- *
848
- * @example
849
- * // Setting up Routes
850
- * setupRoutingModules(): void {
851
- * this.httpPort = env.httpPort;
852
- * this.httpsPort = env.httpsPort;
853
- *
854
- * this.cert = {
855
- * keyPath: Path.join(__dirname, './_assets/cert/ucc.key'),
856
- * certPath: Path.join(__dirname, './_assets/cert/ucc.crt'),
857
- * };
858
- *
859
- * this.routingModules = [
860
- * new DynamoBERountingModule({
861
- * route: '/api/account',
862
- * controllers: [
863
- * AccountController.getInstance(),
864
- * PersonalInformationController.getInstance(),
865
- * ...
866
- * ]
867
- * }),
868
- * new DynamoBERountingModule({
869
- * route: '/api/project',
870
- * controllers: [
871
- * ProjectController.getInstance(),
872
- * ProjectExtensionController.getInstance(),
873
- * ]
874
- * }),
875
- * ...
876
- * ];
877
- * }
930
+ * MISSING Description (TODO)
878
931
  */
879
932
  getRoutingModules?(): DynamoNTS_RoutingModule[];
880
933
 
@@ -201,7 +201,10 @@ 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
210
  Dynamo_Log.success(`<-==> socket(${this.params.name}) subscription successfull (${issuer})`);
@@ -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,7 +431,7 @@ 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
437
  Dynamo_Log.success(` <--= emitted socket(${this.params.name}) event for presence: ${event}, presenceId: ${id}) \ncontent:`, content);
@@ -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
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);