@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 +1 -1
- package/services/pondSocket.js +6 -20
package/package.json
CHANGED
package/services/pondSocket.js
CHANGED
|
@@ -123,7 +123,7 @@ class PondSocketService {
|
|
|
123
123
|
channels: [],
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
|
-
modules.get(module).endpoints.push(endpoint.discoveredClass
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
149
|
+
endpoint: baseEndpoint.discoveredClass,
|
|
157
150
|
channels,
|
|
158
151
|
});
|
|
159
152
|
}
|
|
160
|
-
else
|
|
161
|
-
|
|
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
|
});
|