From 42cb907cfcf76f6a3d6cf9f215a4a0068c627551 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 6 Mar 2025 14:55:02 +0700 Subject: [PATCH] ws test --- src/app.ts | 5 +---- src/services/webSocket.ts | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/app.ts b/src/app.ts index 1fcfdb76..8ea1260c 100644 --- a/src/app.ts +++ b/src/app.ts @@ -13,12 +13,9 @@ import { OrganizationController } from "./controllers/OrganizationController"; import logMiddleware from "./middlewares/logs"; import { CommandController } from "./controllers/CommandController"; import { ProfileSalaryController } from "./controllers/ProfileSalaryController"; -import { WebSocketServer } from "ws"; import http from "http"; +import { wss } from "../src/services/webSocket"; -export const wss = new WebSocketServer({ noServer: true, - path: "/api/v1/org/socket", - }); async function main() { await AppDataSource.initialize(); diff --git a/src/services/webSocket.ts b/src/services/webSocket.ts index 32ea70af..ff8ee3e1 100644 --- a/src/services/webSocket.ts +++ b/src/services/webSocket.ts @@ -1,5 +1,7 @@ -import { WebSocket } from "ws"; -import { wss } from "../app"; +import { WebSocket, WebSocketServer } from "ws"; +export const wss = new WebSocketServer({ noServer: true, + path: "/api/v1/org/socket", + }); export async function sendWebSocket(data:any){ wss.clients.forEach((client: any) => {