Skip to content

Commit 7945a5b

Browse files
committedMar 27, 2024·
add tips for handling auth and add typings for ws
1 parent af5c36d commit 7945a5b

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed
 

‎bin/server.cjs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env node
22

3-
/**
4-
* @type {any}
5-
*/
63
const WebSocket = require('ws')
74
const http = require('http')
85
const number = require('lib0/number')
@@ -20,9 +17,9 @@ const server = http.createServer((_request, response) => {
2017
wss.on('connection', setupWSConnection)
2118

2219
server.on('upgrade', (request, socket, head) => {
23-
// You may check auth of request here.. Call `wss.HandleUpgrade` *after* you
24-
// checked whether the client has access (e.g. by checking cookies, or url
25-
// parameters).
20+
// You may check auth of request here..
21+
// Call `wss.HandleUpgrade` *after* you checked whether the client has access
22+
// (e.g. by checking cookies, or url parameters).
2623
// See https://github.com/websockets/ws#client-authentication
2724
wss.handleUpgrade(request, socket, head, /** @param {any} ws */ ws => {
2825
wss.emit('connection', ws, request)

‎package-lock.json

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
},
6666
"devDependencies": {
6767
"@types/node": "^18.15.0",
68+
"@types/ws": "^8.5.10",
6869
"rollup": "^3.19.1",
6970
"standard": "^12.0.1",
7071
"typescript": "^4.9.5",

0 commit comments

Comments
 (0)
Please sign in to comment.