import { WebSocketServer } from 'ws'; const wss = new WebSocketServer({ port: 8080 }); wss.on('connection', function (ws) { process.stdin.on('data', (x) => { let str = x.toString(); if (str == "\n") { process.exit(); } else { ws.send(str); } }); ws.on('error', console.error); ws.on('message', (x) => { console.log(x.toString()) }); });