zyket 1.0.19 → 1.0.20

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": "zyket",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -43,7 +43,7 @@ module.exports = class SocketIO extends Service {
43
43
  connectionHandler.handle({ container: this.#container, socket, io: this.io });
44
44
  handlers.forEach((handler) => {
45
45
  const handlerGuards = (handler?.guards || []).map(mdl => this.guards[mdl])
46
- socket.on(handler.event, async (data) => {
46
+ socket.on(handler.event, async (data, callback) => {
47
47
  this.#container.get('logger').debug(`[${socket?.id}] Sent ${handler.event} with guards: ${handlerGuards?.map(mdl => mdl?.name).join(", ")}`);
48
48
  for (const guard of handlerGuards) {
49
49
  if(!guard) {
@@ -52,6 +52,9 @@ module.exports = class SocketIO extends Service {
52
52
  }
53
53
  await guard.handle({ container: this.#container, socket, io: this.io });
54
54
  }
55
+ if(callback && typeof callback === 'function') {
56
+ return callback(await handler.handle({ container: this.#container, socket, data, io: this.io }));
57
+ }
55
58
  return await handler.handle({ container: this.#container, socket, data, io: this.io });
56
59
  });
57
60
  });