@nestjs/platform-ws 9.3.11 → 9.4.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.
@@ -16,6 +16,7 @@ export declare class WsAdapter extends AbstractWsAdapter {
16
16
  create(port: number, options?: Record<string, any> & {
17
17
  namespace?: string;
18
18
  server?: any;
19
+ path?: string;
19
20
  }): any;
20
21
  bindMessageHandlers(client: any, handlers: MessageMappingProperties[], transform: (data: any) => Observable<any>): void;
21
22
  bindMessageHandler(buffer: any, handlers: MessageMappingProperties[], transform: (data: any) => Observable<any>): Observable<any>;
@@ -31,7 +31,7 @@ class WsAdapter extends websockets_1.AbstractWsAdapter {
31
31
  wsPackage = (0, load_package_util_1.loadPackage)('ws', 'WsAdapter', () => require('ws'));
32
32
  }
33
33
  create(port, options) {
34
- const { server } = options, wsOptions = tslib_1.__rest(options, ["server"]);
34
+ const { server, path } = options, wsOptions = tslib_1.__rest(options, ["server", "path"]);
35
35
  if (wsOptions === null || wsOptions === void 0 ? void 0 : wsOptions.namespace) {
36
36
  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
37
  this.logger.error(error);
@@ -40,23 +40,24 @@ class WsAdapter extends websockets_1.AbstractWsAdapter {
40
40
  if (port === UNDERLYING_HTTP_SERVER_PORT && this.httpServer) {
41
41
  this.ensureHttpServerExists(port, this.httpServer);
42
42
  const wsServer = this.bindErrorHandler(new wsPackage.Server(Object.assign({ noServer: true }, wsOptions)));
43
- this.addWsServerToRegistry(wsServer, port, options.path || '/');
43
+ this.addWsServerToRegistry(wsServer, port, path);
44
44
  return wsServer;
45
45
  }
46
46
  if (server) {
47
47
  return server;
48
48
  }
49
- if (options.path && port !== UNDERLYING_HTTP_SERVER_PORT) {
49
+ if (path && port !== UNDERLYING_HTTP_SERVER_PORT) {
50
50
  // Multiple servers with different paths
51
51
  // sharing a single HTTP/S server running on different port
52
52
  // than a regular HTTP application
53
53
  const httpServer = this.ensureHttpServerExists(port);
54
54
  httpServer === null || httpServer === void 0 ? void 0 : httpServer.listen(port);
55
55
  const wsServer = this.bindErrorHandler(new wsPackage.Server(Object.assign({ noServer: true }, wsOptions)));
56
- this.addWsServerToRegistry(wsServer, port, options.path);
56
+ this.addWsServerToRegistry(wsServer, port, path);
57
57
  return wsServer;
58
58
  }
59
- const wsServer = this.bindErrorHandler(new wsPackage.Server(Object.assign({ port }, wsOptions)));
59
+ const wsServer = this.bindErrorHandler(new wsPackage.Server(Object.assign({ port,
60
+ path }, wsOptions)));
60
61
  return wsServer;
61
62
  }
62
63
  bindMessageHandlers(client, handlers, transform) {
@@ -126,7 +127,7 @@ class WsAdapter extends websockets_1.AbstractWsAdapter {
126
127
  var _a;
127
128
  const entries = (_a = this.wsServersRegistry.get(port)) !== null && _a !== void 0 ? _a : [];
128
129
  entries.push(wsServer);
129
- wsServer.path = path;
130
+ wsServer.path = (0, shared_utils_1.normalizePath)(path);
130
131
  this.wsServersRegistry.set(port, entries);
131
132
  }
132
133
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/platform-ws",
3
- "version": "9.3.11",
3
+ "version": "9.4.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@platform-ws)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",