From fd5e8ba70ebf7ecd830179cddf5154cc9ec21f9b Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Tue, 27 Aug 2024 10:55:24 +0200 Subject: [PATCH] Lint out the codebase --- src/index.js | 15 ++++++--- .../nonStandardCodesAndHttpAuthentication.js | 33 ++++++++----------- src/middleware/redirectTrailingSlashes.js | 33 +++++++++---------- src/utils/clusterBunShim.js | 2 +- 4 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/index.js b/src/index.js index f3406f9..485c3a8 100644 --- a/src/index.js +++ b/src/index.js @@ -687,17 +687,24 @@ if (!disableMods) { // If there was another error, try creating the temp folder and then the modloader folder again fs.mkdirSync(process.dirname + "/temp"); try { - fs.mkdirSync(process.dirname + "/temp/" + modloaderFolderName); + fs.mkdirSync( + process.dirname + "/temp/" + modloaderFolderName, + ); } catch (err) { // If there was another error, throw it if (err.code != "EEXIST") throw err; } } } - - // Create a subfolder for the current mod within the modloader folder - fs.mkdirSync(process.dirname + "/temp/" + modloaderFolderName + "/" + modFileRaw); + // Create a subfolder for the current mod within the modloader folder + fs.mkdirSync( + process.dirname + + "/temp/" + + modloaderFolderName + + "/" + + modFileRaw, + ); } catch (err) { // If there was an error creating the folder, ignore it if it's a known error if (err.code != "EEXIST" && err.code != "ENOENT") throw err; diff --git a/src/middleware/nonStandardCodesAndHttpAuthentication.js b/src/middleware/nonStandardCodesAndHttpAuthentication.js index 2efe961..f1331ce 100644 --- a/src/middleware/nonStandardCodesAndHttpAuthentication.js +++ b/src/middleware/nonStandardCodesAndHttpAuthentication.js @@ -199,25 +199,20 @@ module.exports = (req, res, logFacilities, config, next) => { if (cacheEntry) { cb(cacheEntry.hash); } else { - crypto.scrypt( - password, - list[_i].salt, - 64, - (err, derivedKey) => { - if (err) { - res.error(500, err); - } else { - const key = derivedKey.toString("hex"); - scryptCache.push({ - hash: key, - password: hashedPassword, - salt: list[_i].salt, - addDate: new Date(), - }); - cb(key); - } - }, - ); + crypto.scrypt(password, list[_i].salt, 64, (err, derivedKey) => { + if (err) { + res.error(500, err); + } else { + const key = derivedKey.toString("hex"); + scryptCache.push({ + hash: key, + password: hashedPassword, + salt: list[_i].salt, + addDate: new Date(), + }); + cb(key); + } + }); } } } else if (list[_i].pbkdf2) { diff --git a/src/middleware/redirectTrailingSlashes.js b/src/middleware/redirectTrailingSlashes.js index 6835d69..472eefb 100644 --- a/src/middleware/redirectTrailingSlashes.js +++ b/src/middleware/redirectTrailingSlashes.js @@ -9,25 +9,22 @@ module.exports = (req, res, logFacilities, config, next) => { req.originalParsedURL.pathname[req.originalParsedURL.pathname.length - 1] != "/" ) { - fs.stat( - "." + decodeURIComponent(req.parsedURL.pathname), - (err, stats) => { - if (err || !stats.isDirectory()) { - try { - next(); - } catch (err) { - res.error(500, err); - } - } else { - res.redirect( - req.originalParsedURL.pathname + - "/" + - req.parsedURL.search + - req.parsedURL.hash, - ); + fs.stat("." + decodeURIComponent(req.parsedURL.pathname), (err, stats) => { + if (err || !stats.isDirectory()) { + try { + next(); + } catch (err) { + res.error(500, err); } - }, - ); + } else { + res.redirect( + req.originalParsedURL.pathname + + "/" + + req.parsedURL.search + + req.parsedURL.hash, + ); + } + }); } else { next(); } diff --git a/src/utils/clusterBunShim.js b/src/utils/clusterBunShim.js index 476036c..51beaf5 100644 --- a/src/utils/clusterBunShim.js +++ b/src/utils/clusterBunShim.js @@ -119,7 +119,7 @@ if (!process.singleThreaded) { let oldLog = console.log; console.log = (...params) => { if ( - a == "ChildProcess.prototype.send() - Sorry! Not implemented yet" + params[0] == "ChildProcess.prototype.send() - Sorry! Not implemented yet" ) { throw new Error("NOT IMPLEMENTED"); } else {