@eleven-am/pondsocket 0.1.100 → 0.1.102

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 (3) hide show
  1. package/nest.js +18 -3
  2. package/package.json +1 -1
  3. package/types.d.ts +1 -1
package/nest.js CHANGED
@@ -657,6 +657,16 @@ const getChannels = (target) => {
657
657
  var _a;
658
658
  return (_a = manageClassData(channelsClassKey, target).get()) !== null && _a !== void 0 ? _a : [];
659
659
  };
660
+ const getGuards = (target) => {
661
+ var _a;
662
+ const classGuards = (_a = manageClassData(pondGuardsKey, target).get()) !== null && _a !== void 0 ? _a : [];
663
+ const methodGuards = Object.getOwnPropertyNames(target.prototype)
664
+ .map((propertyKey) => {
665
+ var _a;
666
+ return (_a = manageMethodData(pondGuardsKey, target.prototype, propertyKey).get()) !== null && _a !== void 0 ? _a : [];
667
+ });
668
+ return [...classGuards, ...methodGuards.flat()];
669
+ };
660
670
  const Endpoint = (metadata) => {
661
671
  var _a;
662
672
  return (0, common_1.applyDecorators)(setChannels(metadata.channels), setEndpoint(metadata.path), setGuards((_a = metadata.guards) !== null && _a !== void 0 ? _a : []));
@@ -738,17 +748,22 @@ class PondSocketService {
738
748
  }
739
749
  class PondSocketModule {
740
750
  static forRoot({ endpoints, providers = [], imports = [], exports = [], isGlobal = false, }) {
741
- const channels = endpoints.flatMap((endpoint) => getChannels(endpoint));
751
+ const endpointsSet = new Set(endpoints);
752
+ const channels = Array.from(endpointsSet).flatMap((endpoint) => getChannels(endpoint));
753
+ const channelsSet = new Set(channels);
754
+ const guards = Array.from(new Set([...endpointsSet, ...channelsSet])).flatMap(((target) => getGuards(target)));
755
+ const guardsSet = new Set(guards);
742
756
  const pondSocketProvider = {
743
757
  provide: PondSocketService,
744
758
  useFactory: (moduleRef, adapterHost) => new PondSocketService(moduleRef, adapterHost, endpoints),
745
759
  inject: [core_1.ModuleRef, core_1.HttpAdapterHost],
746
760
  };
761
+ const providersSet = new Set([...providers, ...guardsSet, ...channelsSet, ...endpointsSet, pondSocketProvider]);
747
762
  return {
748
763
  imports,
749
764
  module: PondSocketModule,
750
- providers: [...providers, ...endpoints, ...channels, pondSocketProvider],
751
- exports: [...exports, ...channels],
765
+ providers: [...providersSet],
766
+ exports: [...exports, ...channelsSet],
752
767
  global: isGlobal,
753
768
  };
754
769
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.100",
3
+ "version": "0.1.102",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
package/types.d.ts CHANGED
@@ -855,7 +855,7 @@ declare function GetLeaveEvent(): ParameterDecorator;
855
855
  * @param callback - The callback to call when the decorator is used
856
856
  * @returns {ReturnType<callback>}
857
857
  */
858
- declare function createParamDecorator<Input> (callback: ParamDecoratorCallback<Input>): ParameterDecorator;
858
+ declare function createParamDecorator<Input> (callback: ParamDecoratorCallback<Input>): (input: Input) => ParameterDecorator;
859
859
 
860
860
  /**
861
861
  * @desc Marks a method as a handler for JoinRequest events. Throwing an error will reject the request with the error message.