@eleven-am/pondsocket-nest 0.0.58 → 0.0.59
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/README.md +2 -11
- package/index.d.ts +1 -0
- package/package.json +2 -2
- package/performers/response.js +4 -1
package/README.md
CHANGED
|
@@ -190,7 +190,7 @@ const endpoint = pond.createEndpoint('/api/socket', (req, res) => {
|
|
|
190
190
|
res.accept({role}); // Assign the user's role to the socket
|
|
191
191
|
} else {
|
|
192
192
|
// Reject the connection for invalid users or without a token
|
|
193
|
-
res.
|
|
193
|
+
res.decline('Invalid token', 401);
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
196
|
|
|
@@ -217,16 +217,7 @@ const profanityChannel = endpoint.createChannel('/channel/:id', async (req, res)
|
|
|
217
217
|
onlineSince: Date.now(),
|
|
218
218
|
})
|
|
219
219
|
// and send the user the channel history
|
|
220
|
-
.
|
|
221
|
-
|
|
222
|
-
// Alternatively, you can also send messages to the user, NOTE that the user would be automatically subscribed to the channel.
|
|
223
|
-
// res.send('history', { messages }, { username, profanityCount: 0 })
|
|
224
|
-
// .trackPresence({
|
|
225
|
-
// username,
|
|
226
|
-
// role,
|
|
227
|
-
// status: 'online',
|
|
228
|
-
// onlineSince: Date.now(),
|
|
229
|
-
// });
|
|
220
|
+
.reply('history', {messages});
|
|
230
221
|
} else {
|
|
231
222
|
// Reject the join request
|
|
232
223
|
res.decline('You do not have the required role to join this channel', 403);
|
package/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ interface Metadata extends Omit<ModuleMetadata, 'controllers'> {
|
|
|
38
38
|
type NestFuncType<Event extends string, Payload extends PondMessage, Presence extends PondPresence, Assigns extends PondAssigns = PondAssigns> = {
|
|
39
39
|
event?: Event;
|
|
40
40
|
broadcast?: Event;
|
|
41
|
+
broadcastFrom?: Event;
|
|
41
42
|
assigns?: Partial<Assigns>;
|
|
42
43
|
presence?: Presence;
|
|
43
44
|
subscribeTo?: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eleven-am/pondsocket-nest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.59",
|
|
4
4
|
"description": "PondSocket is a fast simple socket server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"socket",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"ts-jest": "^29.1.2",
|
|
44
44
|
"ts-loader": "^9.5.1",
|
|
45
45
|
"ts-node": "^10.9.2",
|
|
46
|
-
"typescript": "^5.4.
|
|
46
|
+
"typescript": "^5.4.5"
|
|
47
47
|
},
|
|
48
48
|
"jest": {
|
|
49
49
|
"moduleFileExtensions": [
|
package/performers/response.js
CHANGED
|
@@ -23,7 +23,7 @@ function performResponse(socketId, channel, data, response) {
|
|
|
23
23
|
if (response && response.hasResponded || !isNotEmpty(data)) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const { event, presence, assigns, broadcast, subscribeTo, unsubscribeFrom } = data, rest = __rest(data, ["event", "presence", "assigns", "broadcast", "subscribeTo", "unsubscribeFrom"]);
|
|
26
|
+
const { event, presence, assigns, broadcast, broadcastFrom, subscribeTo, unsubscribeFrom } = data, rest = __rest(data, ["event", "presence", "assigns", "broadcast", "broadcastFrom", "subscribeTo", "unsubscribeFrom"]);
|
|
27
27
|
if (response) {
|
|
28
28
|
if ((0, narrow_1.isConnectionResponse)(response) || (0, narrow_1.isJoinResponse)(response)) {
|
|
29
29
|
response
|
|
@@ -41,6 +41,9 @@ function performResponse(socketId, channel, data, response) {
|
|
|
41
41
|
if (broadcast && ((0, narrow_1.isJoinResponse)(response) || (0, narrow_1.isEventResponse)(response))) {
|
|
42
42
|
response.broadcast(broadcast, rest);
|
|
43
43
|
}
|
|
44
|
+
if (broadcastFrom && (0, narrow_1.isEventResponse)(response)) {
|
|
45
|
+
response.broadcastFrom(broadcastFrom, rest);
|
|
46
|
+
}
|
|
44
47
|
}
|
|
45
48
|
if (subscribeTo) {
|
|
46
49
|
subscribeTo.forEach((channelName) => {
|