From 2eede78b361f59292ca6fc39ad2bb3c3c828f602 Mon Sep 17 00:00:00 2001 From: Mike Johanson Date: Thu, 12 Dec 2024 14:15:02 -0700 Subject: [PATCH] refactor: adjust types for websockets --- src/server/webserver.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server/webserver.ts b/src/server/webserver.ts index 3b569e63b..39600895a 100644 --- a/src/server/webserver.ts +++ b/src/server/webserver.ts @@ -19,7 +19,7 @@ import { type certificatesType } from '../models/Config.js' import { ErrorResponse } from '../utils/amtHelper.js' import { logger, messages } from '../logging/index.js' import routes from '../routes/index.js' -import WebSocket from 'ws' +import { WebSocketServer, ServerOptions, WebSocket } from 'ws' import { URL, fileURLToPath, pathToFileURL } from 'node:url' import cors from 'cors' import { lstatSync, existsSync, readdirSync } from 'node:fs' @@ -32,7 +32,7 @@ import path from 'node:path' export class WebServer { app: express.Express server: Server = null - relayWSS: WebSocket.Server = null + relayWSS: WebSocketServer = null secrets: ISecretManagerService certs: certificatesType // to unit test code @@ -49,11 +49,11 @@ export class WebServer { this.certs = certs this.app = express() - const options: WebSocket.ServerOptions = { + const options: ServerOptions = { noServer: true, verifyClient: (info) => this.verifyClientToken(info) } - this.relayWSS = new WebSocket.Server(options) + this.relayWSS = new WebSocketServer(options) // Create Server this.server = createServer(this.app)