From e5b367e10d469bd8410b80cfe90d7a6388d74c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e=20Kooi?= Date: Fri, 6 Dec 2024 12:12:28 +0100 Subject: [PATCH] lint --- src/HttpApi.js | 10 +++++----- src/SocketServer.js | 4 +++- src/controllers/authenticate.js | 8 -------- src/sockets/AuthedConnection.js | 4 +++- src/sockets/LostConnection.js | 4 +++- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/HttpApi.js b/src/HttpApi.js index 2a73956b..ca0794df 100644 --- a/src/HttpApi.js +++ b/src/HttpApi.js @@ -127,12 +127,12 @@ async function httpApi(uw, options) { * @param {string} sid * @param {(err?: Error, data?: session.SessionData | null) => void} callback */ - get (sid, callback) { + get(sid, callback) { uw.redis.get(`session:${sid}`).then((data) => { callback(undefined, data == null ? null : JSON.parse(data)); }, (err) => { callback(err); - }) + }); } /** @@ -145,7 +145,7 @@ async function httpApi(uw, options) { callback(); }, (err) => { callback(err); - }) + }); } /** @@ -157,9 +157,9 @@ async function httpApi(uw, options) { callback(); }, (err) => { callback(err); - }) + }); } - }, + }(), })) .use(uw.passport.initialize()) .use(addFullUrl()) diff --git a/src/SocketServer.js b/src/SocketServer.js index 916d01e2..980362d8 100644 --- a/src/SocketServer.js +++ b/src/SocketServer.js @@ -455,7 +455,9 @@ class SocketServer { */ async initLostConnections() { const { db, redis } = this.#uw; - const userIDs = /** @type {import('./schema').UserID[]} */ (await redis.lrange(REDIS_ACTIVE_SESSIONS, 0, -1)); + const userIDs = /** @type {import('./schema').UserID[]} */ ( + await redis.lrange(REDIS_ACTIVE_SESSIONS, 0, -1) + ); const disconnectedIDs = userIDs.filter((userID) => !this.connection(userID)); if (disconnectedIDs.length === 0) { diff --git a/src/controllers/authenticate.js b/src/controllers/authenticate.js index dba63560..5aa5507e 100644 --- a/src/controllers/authenticate.js +++ b/src/controllers/authenticate.js @@ -3,7 +3,6 @@ import cookie from 'cookie'; import jwt from 'jsonwebtoken'; import randomString from 'random-string'; import nodeFetch from 'node-fetch'; -import ms from 'ms'; import htmlescape from 'htmlescape'; import httpErrors from 'http-errors'; import nodemailer from 'nodemailer'; @@ -37,13 +36,6 @@ const { BadRequest } = httpErrors; * @prop {AuthenticateOptions} authOptions */ -/** - * @param {string} str - */ -function seconds(str) { - return Math.floor(ms(str) / 1000); -} - /** * @type {import('../types.js').Controller} */ diff --git a/src/sockets/AuthedConnection.js b/src/sockets/AuthedConnection.js index f09ea6f7..f4bebff7 100644 --- a/src/sockets/AuthedConnection.js +++ b/src/sockets/AuthedConnection.js @@ -19,7 +19,9 @@ class AuthedConnection extends EventEmitter { this.events = new Ultron(this.socket); this.user = user; this.sessionID = sessionID; - this.#logger = uw.logger.child({ ns: 'uwave:sockets', connectionType: 'AuthedConnection', userId: this.user.id, sessionID }); + this.#logger = uw.logger.child({ + ns: 'uwave:sockets', connectionType: 'AuthedConnection', userId: this.user.id, sessionID, + }); this.events.on('close', () => { this.emit('close', { banned: this.banned }); diff --git a/src/sockets/LostConnection.js b/src/sockets/LostConnection.js index ec5fb150..cf66c3bf 100644 --- a/src/sockets/LostConnection.js +++ b/src/sockets/LostConnection.js @@ -14,7 +14,9 @@ class LostConnection extends EventEmitter { this.user = user; this.sessionID = sessionID; this.timeout = timeout; - this.#logger = uw.logger.child({ ns: 'uwave:sockets', connectionType: 'LostConnection', userID: this.user.id, sessionID }); + this.#logger = uw.logger.child({ + ns: 'uwave:sockets', connectionType: 'LostConnection', userID: this.user.id, sessionID, + }); this.initQueued(); this.setTimeout(timeout);