chore(websocket): bump dependencies (#17325)

* chore(websocket): bump dependencies

* bump client-ws-app

* bump more packages
This commit is contained in:
Ville Brofeldt 2021-11-03 11:17:36 +01:00 committed by GitHub
parent 2199ef2dd7
commit 33bcf82fa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 3734 additions and 6825 deletions

File diff suppressed because it is too large Load Diff

View File

@ -16,29 +16,33 @@
"license": "Apache-2.0",
"dependencies": {
"cookie": "^0.4.1",
"hot-shots": "^8.3.1",
"ioredis": "^4.16.1",
"hot-shots": "^9.0.0",
"ioredis": "^4.28.0",
"jsonwebtoken": "^8.5.1",
"uuid": "^8.3.2",
"winston": "^3.3.3",
"ws": "^7.4.2"
"ws": "^8.2.3"
},
"devDependencies": {
"@types/cookie": "^0.4.0",
"@types/ioredis": "^4.22.0",
"@types/jest": "^26.0.20",
"@types/jsonwebtoken": "^8.5.1",
"@types/node": "^14.14.22",
"@types/uuid": "^8.3.0",
"@types/ws": "^7.4.0",
"@types/cookie": "^0.4.1",
"@types/ioredis": "^4.27.8",
"@types/jest": "^27.0.2",
"@types/jsonwebtoken": "^8.5.5",
"@types/node": "^16.11.6",
"@types/uuid": "^8.3.1",
"@types/ws": "^8.2.0",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"jest": "^26.6.3",
"prettier": "2.2.1",
"ts-jest": "^26.5.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "^7.1.0",
"jest": "^27.3.1",
"prettier": "^2.4.1",
"ts-jest": "^27.0.7",
"ts-node": "^9.1.1",
"typescript": "^4.2.3"
},
"engines": {
"node": "^16.9.1",
"npm": "^7.5.4"
}
}

View File

@ -22,7 +22,7 @@ const config = require('../config.test.json');
import { describe, expect, test, beforeEach, afterEach } from '@jest/globals';
import * as http from 'http';
import * as net from 'net';
import WebSocket from 'ws';
import { WebSocket } from 'ws';
// NOTE: these mock variables needs to start with "mock" due to
// calls to `jest.mock` being hoisted to the top of the file.
@ -459,6 +459,18 @@ describe('server', () => {
});
});
const setReadyState = (ws: WebSocket, value: typeof ws.readyState) => {
// workaround for not being able to do
// spyOn(instance,'readyState','get').and.returnValue(value);
// See for details: https://github.com/facebook/jest/issues/9675
Object.defineProperty(ws, 'readyState', {
configurable: true,
get() {
return value;
},
});
};
describe('checkSockets', () => {
let ws: WebSocket;
let pingSpy: jest.SpyInstance;
@ -473,7 +485,7 @@ describe('server', () => {
});
test('active sockets', () => {
ws.readyState = WebSocket.OPEN;
setReadyState(ws, WebSocket.OPEN);
server.trackClient(channelId, socketInstance);
server.checkSockets();
@ -484,7 +496,7 @@ describe('server', () => {
});
test('stale sockets', () => {
ws.readyState = WebSocket.OPEN;
setReadyState(ws, WebSocket.OPEN);
socketInstance.pongTs = Date.now() - 60000;
server.trackClient(channelId, socketInstance);
@ -496,7 +508,7 @@ describe('server', () => {
});
test('closed sockets', () => {
ws.readyState = WebSocket.CLOSED;
setReadyState(ws, WebSocket.CLOSED);
server.trackClient(channelId, socketInstance);
server.checkSockets();
@ -522,7 +534,7 @@ describe('server', () => {
});
test('active sockets', () => {
ws.readyState = WebSocket.OPEN;
setReadyState(ws, WebSocket.OPEN);
server.trackClient(channelId, socketInstance);
server.cleanChannel(channelId);
@ -531,7 +543,7 @@ describe('server', () => {
});
test('closing sockets', () => {
ws.readyState = WebSocket.CLOSING;
setReadyState(ws, WebSocket.CLOSING);
server.trackClient(channelId, socketInstance);
server.cleanChannel(channelId);
@ -540,11 +552,11 @@ describe('server', () => {
});
test('multiple sockets', () => {
ws.readyState = WebSocket.OPEN;
setReadyState(ws, WebSocket.OPEN);
server.trackClient(channelId, socketInstance);
const ws2 = new wsMock('localhost');
ws2.readyState = WebSocket.OPEN;
setReadyState(ws2, WebSocket.OPEN);
const socketInstance2 = {
ws: ws2,
channel: channelId,
@ -556,7 +568,7 @@ describe('server', () => {
expect(server.channels[channelId].sockets.length).toBe(2);
ws2.readyState = WebSocket.CLOSED;
setReadyState(ws2, WebSocket.CLOSED);
server.cleanChannel(channelId);
expect(server.channels[channelId].sockets.length).toBe(1);

View File

@ -118,7 +118,7 @@ export const wss = new WebSocket.Server({
clientTracking: false,
});
const SOCKET_ACTIVE_STATES = [WebSocket.OPEN, WebSocket.CONNECTING];
const SOCKET_ACTIVE_STATES: number[] = [WebSocket.OPEN, WebSocket.CONNECTING];
const GLOBAL_EVENT_STREAM_NAME = `${opts.redisStreamPrefix}full`;
const DEFAULT_STREAM_LAST_ID = '$';

View File

@ -28,7 +28,7 @@ var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.set('view engine', 'pug');
app.use(logger('dev'));
app.use(express.json());

File diff suppressed because it is too large Load Diff

View File

@ -6,12 +6,12 @@
"start": "node ./bin/www"
},
"dependencies": {
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"express": "~4.16.1",
"http-errors": "~1.6.3",
"jade": "~1.11.0",
"cookie-parser": "~1.4.5",
"debug": "~4.3.2",
"express": "~4.17.1",
"http-errors": "~1.8.0",
"jsonwebtoken": "^8.5.1",
"morgan": "~1.9.1"
"morgan": "~1.10.0",
"pug": "~3.0.2"
}
}