@nestjs/platform-ws
Advanced tools
Comparing version 9.4.3 to 10.0.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WsAdapter = void 0; | ||
const tslib_1 = require("tslib"); | ||
const common_1 = require("@nestjs/common"); | ||
@@ -34,4 +33,4 @@ const load_package_util_1 = require("@nestjs/common/utils/load-package.util"); | ||
create(port, options) { | ||
const { server, path } = options, wsOptions = tslib_1.__rest(options, ["server", "path"]); | ||
if (wsOptions === null || wsOptions === void 0 ? void 0 : wsOptions.namespace) { | ||
const { server, path, ...wsOptions } = options; | ||
if (wsOptions?.namespace) { | ||
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.'); | ||
@@ -43,3 +42,6 @@ this.logger.error(error); | ||
this.ensureHttpServerExists(port, this.httpServer); | ||
const wsServer = this.bindErrorHandler(new wsPackage.Server(Object.assign({ noServer: true }, wsOptions))); | ||
const wsServer = this.bindErrorHandler(new wsPackage.Server({ | ||
noServer: true, | ||
...wsOptions, | ||
})); | ||
this.addWsServerToRegistry(wsServer, port, path); | ||
@@ -56,9 +58,15 @@ return wsServer; | ||
const httpServer = this.ensureHttpServerExists(port); | ||
httpServer === null || httpServer === void 0 ? void 0 : httpServer.listen(port); | ||
const wsServer = this.bindErrorHandler(new wsPackage.Server(Object.assign({ noServer: true }, wsOptions))); | ||
httpServer?.listen(port); | ||
const wsServer = this.bindErrorHandler(new wsPackage.Server({ | ||
noServer: true, | ||
...wsOptions, | ||
})); | ||
this.addWsServerToRegistry(wsServer, port, path); | ||
return wsServer; | ||
} | ||
const wsServer = this.bindErrorHandler(new wsPackage.Server(Object.assign({ port, | ||
path }, wsOptions))); | ||
const wsServer = this.bindErrorHandler(new wsPackage.Server({ | ||
port, | ||
path, | ||
...wsOptions, | ||
})); | ||
return wsServer; | ||
@@ -84,3 +92,3 @@ } | ||
} | ||
catch (_a) { | ||
catch { | ||
return rxjs_1.EMPTY; | ||
@@ -131,4 +139,3 @@ } | ||
addWsServerToRegistry(wsServer, port, path) { | ||
var _a; | ||
const entries = (_a = this.wsServersRegistry.get(port)) !== null && _a !== void 0 ? _a : []; | ||
const entries = this.wsServersRegistry.get(port) ?? []; | ||
entries.push(wsServer); | ||
@@ -135,0 +142,0 @@ wsServer.path = (0, shared_utils_1.normalizePath)(path); |
{ | ||
"name": "@nestjs/platform-ws", | ||
"version": "9.4.3", | ||
"version": "10.0.0", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@platform-ws)", | ||
@@ -25,6 +25,6 @@ "author": "Kamil Mysliwiec", | ||
"peerDependencies": { | ||
"@nestjs/common": "^9.0.0", | ||
"@nestjs/websockets": "^9.0.0", | ||
"@nestjs/common": "^10.0.0", | ||
"@nestjs/websockets": "^10.0.0", | ||
"rxjs": "^7.1.0" | ||
} | ||
} |
208
27912