@eleven-am/pondsocket-nest 0.0.31 → 0.0.34

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.
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.manageGuards = void 0;
3
+ exports.getLocalGuards = exports.manageGuards = void 0;
4
4
  const class_1 = require("./class");
5
5
  const method_1 = require("./method");
6
6
  const constants_1 = require("../constants");
7
+ const localGuards = new Set();
7
8
  function manageGuards(target, propertyKey) {
8
9
  let getter;
9
10
  let setter;
@@ -23,7 +24,12 @@ function manageGuards(target, propertyKey) {
23
24
  var _a;
24
25
  const current = (_a = getter()) !== null && _a !== void 0 ? _a : [];
25
26
  setter([...value, ...current]);
27
+ value.forEach((guard) => localGuards.add(guard));
26
28
  },
27
29
  };
28
30
  }
29
31
  exports.manageGuards = manageGuards;
32
+ function getLocalGuards() {
33
+ return Array.from(localGuards);
34
+ }
35
+ exports.getLocalGuards = getLocalGuards;
@@ -4,14 +4,17 @@ exports.PondSocketModule = void 0;
4
4
  const nestjs_discovery_1 = require("@golevelup/nestjs-discovery");
5
5
  // eslint-disable-next-line import/no-unresolved
6
6
  const core_1 = require("@nestjs/core");
7
+ const guards_1 = require("../managers/guards");
7
8
  const pondSocket_1 = require("../services/pondSocket");
8
9
  class PondSocketModule {
9
10
  static forRoot({ guards = [], providers = [], imports = [], exports = [], isGlobal = false, }) {
11
+ const localGuards = (0, guards_1.getLocalGuards)();
10
12
  const pondSocketProvider = {
11
13
  provide: pondSocket_1.PondSocketService,
12
14
  useFactory: (moduleRef, adapterHost, discovery) => new pondSocket_1.PondSocketService(moduleRef, discovery, adapterHost, guards),
13
15
  inject: [core_1.ModuleRef, core_1.HttpAdapterHost, nestjs_discovery_1.DiscoveryService],
14
16
  };
17
+ guards = [...new Set([...localGuards, ...guards])];
15
18
  return {
16
19
  exports,
17
20
  global: isGlobal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket-nest",
3
- "version": "0.0.31",
3
+ "version": "0.0.34",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -28,14 +28,14 @@
28
28
  "pipeline": "npm run lint && npm run build && npm run push"
29
29
  },
30
30
  "dependencies": {
31
- "@eleven-am/pondsocket": "^0.1.146",
31
+ "@eleven-am/pondsocket": "^0.1.147",
32
32
  "@golevelup/nestjs-discovery": "^4.0.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@nestjs/common": "^10.3.3",
36
36
  "@nestjs/core": "^10.3.3",
37
37
  "@types/jest": "^29.5.12",
38
- "@typescript-eslint/eslint-plugin": "^7.0.2",
38
+ "@typescript-eslint/eslint-plugin": "^7.1.0",
39
39
  "eslint-plugin-file-progress": "^1.3.0",
40
40
  "eslint-plugin-import": "^2.29.1",
41
41
  "jest": "^29.7.0",
@@ -143,15 +143,17 @@ class PondSocketService {
143
143
  channels: instance.channels,
144
144
  }))).flat();
145
145
  const baseEndpoint = endpoints.find((endpoint) => endpoint.discoveredClass.parentModule.name === 'AppModule');
146
- if (channelsWithNoEndpoints.length > 0 && baseEndpoint) {
147
- const channels = channelsWithNoEndpoints.map((instance) => instance.channels).flat();
148
- groupedInstances.push({
149
- endpoint: baseEndpoint.discoveredClass,
150
- channels,
151
- });
152
- }
153
- else {
154
- throw new Error('No base endpoint found');
146
+ if (channelsWithNoEndpoints.length > 0) {
147
+ if (baseEndpoint) {
148
+ const channels = channelsWithNoEndpoints.map((instance) => instance.channels).flat();
149
+ groupedInstances.push({
150
+ endpoint: baseEndpoint.discoveredClass,
151
+ channels,
152
+ });
153
+ }
154
+ else {
155
+ throw new Error('No base endpoint found');
156
+ }
155
157
  }
156
158
  return groupedInstances;
157
159
  });