koa-websocket
Advanced tools
Comparing version 6.0.0 to 7.0.0
@@ -21,3 +21,2 @@ const koa = require('koa'); | ||
app.listen(3000); |
{ | ||
"name": "koa-websocket", | ||
"version": "6.0.0", | ||
"version": "7.0.0", | ||
"description": "Light wrapper around Koa providing a websocket middleware handler that is koa-route compatible.", | ||
@@ -28,17 +28,17 @@ "main": "index.js", | ||
"dependencies": { | ||
"co": "^4.4.0", | ||
"debug": "^4.0.1", | ||
"co": "^4.6.0", | ||
"debug": "^4.3.4", | ||
"koa-compose": "^4.1.0", | ||
"ws": "^7.0.1" | ||
"ws": "^8.5.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.0.1", | ||
"eslint-config-airbnb": "^17.1.1", | ||
"eslint-plugin-import": "^2.18.0", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-react": "^7.14.2", | ||
"koa": "^2.5.3", | ||
"eslint": "^8.13.0", | ||
"eslint-config-airbnb": "^19.0.4", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jsx-a11y": "^6.5.1", | ||
"eslint-plugin-react": "^7.29.4", | ||
"koa": "^2.13.4", | ||
"koa-route": "^3.2.0", | ||
"mocha": "^6.1.4" | ||
"mocha": "^9.2.2" | ||
} | ||
} |
# koa-websocket | ||
[![Circle CI](https://circleci.com/gh/kudos/koa-websocket.svg?style=svg)](https://circleci.com/gh/kudos/koa-websocket) | ||
[![CI Status](https://github.com/kudos/koa-websocket/actions/workflows/node.js.yml/badge.svg)](https://github.com/kudos/koa-websocket/actions) | ||
@@ -5,0 +5,0 @@ > Koa v2 is now the default. For Koa v1 support install with koa-websocket@2 and see the `legacy` branch. |
@@ -14,3 +14,3 @@ const assert = require('assert'); | ||
ctx.websocket.on('message', (message) => { | ||
if (message === '123') { | ||
if (message.toString() === '123') { | ||
ctx.websocket.send(message); | ||
@@ -28,8 +28,2 @@ } | ||
app.ws.use(route.all('/abc', (ctx) => { | ||
ctx.websocket.on('message', (message) => { | ||
ctx.websocket.send(message); | ||
}); | ||
})); | ||
app.ws.use(route.all('/def', (ctx) => { | ||
@@ -56,4 +50,4 @@ ctx.websocket.on('message', (message) => { | ||
}); | ||
ws.on('message', (message) => { | ||
assert(message === '123'); | ||
ws.on('message', (data) => { | ||
assert(data.toString() === '123'); | ||
done(); | ||
@@ -69,4 +63,4 @@ ws.close(); | ||
}); | ||
ws.on('message', (message) => { | ||
assert(message === 'abc'); | ||
ws.on('message', (data) => { | ||
assert(data.toString() === 'abc'); | ||
done(); | ||
@@ -82,4 +76,4 @@ ws.close(); | ||
}); | ||
ws.on('message', (message) => { | ||
assert(message === 'def'); | ||
ws.on('message', (data) => { | ||
assert(data.toString() === 'def'); | ||
done(); | ||
@@ -95,4 +89,4 @@ ws.close(); | ||
}); | ||
ws.on('message', (message) => { | ||
assert(message === 'abc'); | ||
ws.on('message', (data) => { | ||
assert(data.toString() === 'abc'); | ||
done(); | ||
@@ -107,3 +101,3 @@ ws.close(); | ||
handleProtocols(protocols) { | ||
if (protocols.indexOf('bad_protocol') !== -1) { return false; } | ||
if (protocols.has('bad_protocol')) { return false; } | ||
return protocols.pop(); | ||
@@ -110,0 +104,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18542
16
213
+ Addedws@8.18.0(transitive)
- Removedws@7.5.10(transitive)
Updatedco@^4.6.0
Updateddebug@^4.3.4
Updatedws@^8.5.0