mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
The `nodejs-websocket` package has been replace with the `ws` package. Both provide `WebSocket` server support and both of zero transitive dependencies. However, the `ws` package has ~78 million weekly downloads and was last updated this week (as of the writing of this commit) while the `nodejs-websocket` package has ~7,600 weekly downloads and was last update 5 years ago. The `ws` package is also already a transitive dependency of the repository which allows for a reduction in the total dependency count for the repository. PR Close #53482
19 lines
592 B
JavaScript
19 lines
592 B
JavaScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
const {WebSocketServer} = require('ws');
|
|
|
|
// simple echo server
|
|
const wss = new WebSocketServer({port: 8001});
|
|
wss.on('connection', (ws) => {ws.on('message', (data) => {
|
|
if (data.toString() === 'close') {
|
|
wss.close();
|
|
return;
|
|
}
|
|
ws.send(data);
|
|
})});
|