mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-06-20 00:38:39 +00:00
17 lines
489 B
TypeScript
17 lines
489 B
TypeScript
import { WebSocketServer } from 'ws';
|
|
import { handleConnection } from './connectionManager';
|
|
import http from 'http';
|
|
import { getPort } from '../config';
|
|
import logger from '../utils/logger';
|
|
|
|
export const initServer = (
|
|
server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>,
|
|
) => {
|
|
const port = getPort();
|
|
const wss = new WebSocketServer({ server });
|
|
|
|
wss.on('connection', handleConnection);
|
|
|
|
logger.info(`WebSocket server started on port ${port}`);
|
|
};
|