redweb 0.4.7 → 0.4.8

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": "redweb",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "A way to quickly set up an express server",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -2,7 +2,7 @@ const WebSocket = require('ws');
2
2
 
3
3
  /**
4
4
  * @typedef {Object} SocketServerOptions
5
- * @property {any} [server] - The existing server instance.
5
+ * @property {import('express').Application} [server] - The existing server instance.
6
6
  * @property {number} [port=3000] - The port number to bind the socket server.
7
7
  * @property {Function} [connectionOpenCallback] - Callback function to execute once a client connects.
8
8
  * @property {Function} [connectionCloseCallback] - Callback function to execute once a client disconnects.
@@ -36,6 +36,7 @@ function broadcast(socketServer, message) {
36
36
  class BaseSocketServer {
37
37
  /**
38
38
  * Base Socket Server
39
+ * @param {import('express').Application} server - The express application instance.
39
40
  * @param {SocketServerOptions} options - Configuration options for SocketServer.
40
41
  */
41
42
  constructor(server, options = {}) {
@@ -63,7 +64,7 @@ class BaseSocketServer {
63
64
  console.info(`Received message from ${ip}: ${message}`);
64
65
  if (this.messageCallback) this.messageCallback(socket, message);
65
66
 
66
- const { type, data } = JSON.parse(message);
67
+ const { type, ...data } = JSON.parse(message);
67
68
  if (this.messageHandlers[type]) {
68
69
  this.messageHandlers[type](socket, data);
69
70
  }