@eleven-am/pondsocket-nest 0.0.26 → 0.0.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket-nest",
3
- "version": "0.0.26",
3
+ "version": "0.0.29",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -123,7 +123,7 @@ class PondSocketService {
123
123
  channels: [],
124
124
  });
125
125
  }
126
- modules.get(module).endpoints.push(endpoint.discoveredClass.instance);
126
+ modules.get(module).endpoints.push(endpoint.discoveredClass);
127
127
  });
128
128
  channels.forEach((channel) => {
129
129
  const module = channel.discoveredClass.parentModule.injectType;
@@ -133,39 +133,25 @@ class PondSocketService {
133
133
  channels: [],
134
134
  });
135
135
  }
136
- if (Array.isArray(channel.discoveredClass.instance)) {
137
- modules.get(module).channels.push(...channel.discoveredClass.instance);
138
- }
139
- else {
140
- modules.get(module).channels.push(channel.discoveredClass.instance);
141
- }
136
+ modules.get(module).channels.push(channel.discoveredClass);
142
137
  });
143
138
  const instances = [...modules.values()];
144
139
  const channelsWithNoEndpoints = instances.filter((instance) => instance.channels.length > 0 && instance.endpoints.length === 0);
145
140
  const channelsWithEndpoints = instances.filter((instance) => instance.channels.length > 0 && instance.endpoints.length > 0);
146
- const endpointsWithNoChannels = instances.filter((instance) => instance.endpoints.length > 0 && instance.channels.length === 0);
147
141
  const groupedInstances = channelsWithEndpoints.map((instance) => instance.endpoints.map((endpoint) => ({
148
142
  endpoint,
149
143
  channels: instance.channels,
150
144
  }))).flat();
151
145
  const baseEndpoint = endpoints.find((endpoint) => endpoint.discoveredClass.parentModule.name === 'AppModule');
152
- const baseEndpointInstance = groupedInstances.find((groupedInstance) => groupedInstance.endpoint.instance === (baseEndpoint === null || baseEndpoint === void 0 ? void 0 : baseEndpoint.discoveredClass.instance));
153
- if (channelsWithNoEndpoints.length > 0 && baseEndpointInstance) {
146
+ if (channelsWithNoEndpoints.length > 0 && baseEndpoint) {
154
147
  const channels = channelsWithNoEndpoints.map((instance) => instance.channels).flat();
155
148
  groupedInstances.push({
156
- endpoint: baseEndpointInstance.endpoint,
149
+ endpoint: baseEndpoint.discoveredClass,
157
150
  channels,
158
151
  });
159
152
  }
160
- else if (channelsWithNoEndpoints.length > 0) {
161
- const endpoints = endpointsWithNoChannels.map((instance) => instance.endpoints).flat();
162
- const channels = channelsWithNoEndpoints.map((instance) => instance.channels).flat();
163
- endpoints.forEach((endpoint) => {
164
- groupedInstances.push({
165
- endpoint,
166
- channels,
167
- });
168
- });
153
+ else {
154
+ throw new Error('No base endpoint found');
169
155
  }
170
156
  return groupedInstances;
171
157
  });