@nestjs/platform-ws 9.4.3 → 10.0.0

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.
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WsAdapter = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const common_1 = require("@nestjs/common");
6
5
  const load_package_util_1 = require("@nestjs/common/utils/load-package.util");
7
6
  const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
@@ -31,15 +30,18 @@ class WsAdapter extends websockets_1.AbstractWsAdapter {
31
30
  wsPackage = (0, load_package_util_1.loadPackage)('ws', 'WsAdapter', () => require('ws'));
32
31
  }
33
32
  create(port, options) {
34
- const { server, path } = options, wsOptions = tslib_1.__rest(options, ["server", "path"]);
35
- if (wsOptions === null || wsOptions === void 0 ? void 0 : wsOptions.namespace) {
33
+ const { server, path, ...wsOptions } = options;
34
+ if (wsOptions?.namespace) {
36
35
  const error = new Error('"WsAdapter" does not support namespaces. If you need namespaces in your project, consider using the "@nestjs/platform-socket.io" package instead.');
37
36
  this.logger.error(error);
38
37
  throw error;
39
38
  }
40
39
  if (port === UNDERLYING_HTTP_SERVER_PORT && this.httpServer) {
41
40
  this.ensureHttpServerExists(port, this.httpServer);
42
- const wsServer = this.bindErrorHandler(new wsPackage.Server(Object.assign({ noServer: true }, wsOptions)));
41
+ const wsServer = this.bindErrorHandler(new wsPackage.Server({
42
+ noServer: true,
43
+ ...wsOptions,
44
+ }));
43
45
  this.addWsServerToRegistry(wsServer, port, path);
44
46
  return wsServer;
45
47
  }
@@ -51,13 +53,19 @@ class WsAdapter extends websockets_1.AbstractWsAdapter {
51
53
  // sharing a single HTTP/S server running on different port
52
54
  // than a regular HTTP application
53
55
  const httpServer = this.ensureHttpServerExists(port);
54
- httpServer === null || httpServer === void 0 ? void 0 : httpServer.listen(port);
55
- const wsServer = this.bindErrorHandler(new wsPackage.Server(Object.assign({ noServer: true }, wsOptions)));
56
+ httpServer?.listen(port);
57
+ const wsServer = this.bindErrorHandler(new wsPackage.Server({
58
+ noServer: true,
59
+ ...wsOptions,
60
+ }));
56
61
  this.addWsServerToRegistry(wsServer, port, path);
57
62
  return wsServer;
58
63
  }
59
- const wsServer = this.bindErrorHandler(new wsPackage.Server(Object.assign({ port,
60
- path }, wsOptions)));
64
+ const wsServer = this.bindErrorHandler(new wsPackage.Server({
65
+ port,
66
+ path,
67
+ ...wsOptions,
68
+ }));
61
69
  return wsServer;
62
70
  }
63
71
  bindMessageHandlers(client, handlers, transform) {
@@ -78,7 +86,7 @@ class WsAdapter extends websockets_1.AbstractWsAdapter {
78
86
  const { callback } = messageHandler;
79
87
  return transform(callback(message.data));
80
88
  }
81
- catch (_a) {
89
+ catch {
82
90
  return rxjs_1.EMPTY;
83
91
  }
84
92
  }
@@ -124,8 +132,7 @@ class WsAdapter extends websockets_1.AbstractWsAdapter {
124
132
  return httpServer;
125
133
  }
126
134
  addWsServerToRegistry(wsServer, port, path) {
127
- var _a;
128
- const entries = (_a = this.wsServersRegistry.get(port)) !== null && _a !== void 0 ? _a : [];
135
+ const entries = this.wsServersRegistry.get(port) ?? [];
129
136
  entries.push(wsServer);
130
137
  wsServer.path = (0, shared_utils_1.normalizePath)(path);
131
138
  this.wsServersRegistry.set(port, entries);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/platform-ws",
3
- "version": "9.4.3",
3
+ "version": "10.0.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@platform-ws)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -22,8 +22,8 @@
22
22
  "ws": "8.13.0"
23
23
  },
24
24
  "peerDependencies": {
25
- "@nestjs/common": "^9.0.0",
26
- "@nestjs/websockets": "^9.0.0",
25
+ "@nestjs/common": "^10.0.0",
26
+ "@nestjs/websockets": "^10.0.0",
27
27
  "rxjs": "^7.1.0"
28
28
  }
29
29
  }