From fa5ba18fe172f0046b4074e3170c2ffe69b42062 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 20:10:34 +0000 Subject: [PATCH 1/3] Initial plan From eb962d8761f6223a744e7cf37395c21ac0f5b013 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 20:17:07 +0000 Subject: [PATCH 2/3] Refactor route files to use guard clauses instead of if/else Co-authored-by: cubap <1119165+cubap@users.noreply.github.com> --- routes/patchSet.js | 7 +++---- routes/patchUnset.js | 7 +++---- routes/patchUpdate.js | 7 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/routes/patchSet.js b/routes/patchSet.js index ff67ec1a..4694b4e3 100644 --- a/routes/patchSet.js +++ b/routes/patchSet.js @@ -8,14 +8,13 @@ import rest from '../rest.js' router.route('/') .patch(auth.checkJwt, controller.patchSet) .post(auth.checkJwt, (req, res, next) => { - if (rest.checkPatchOverrideSupport(req, res)) { - controller.patchSet(req, res, next) - } - else { + if (!rest.checkPatchOverrideSupport(req, res)) { res.statusMessage = 'Improper request method for updating, please use PATCH to add new keys to this object.' res.status(405) next(res) + return } + controller.patchSet(req, res, next) }) .all((req, res, next) => { res.statusMessage = 'Improper request method for updating, please use PATCH to add new keys to this object.' diff --git a/routes/patchUnset.js b/routes/patchUnset.js index 6bdf0b65..43c0a457 100644 --- a/routes/patchUnset.js +++ b/routes/patchUnset.js @@ -8,14 +8,13 @@ import rest from '../rest.js' router.route('/') .patch(auth.checkJwt, controller.patchUnset) .post(auth.checkJwt, (req, res, next) => { - if (rest.checkPatchOverrideSupport(req, res)) { - controller.patchUnset(req, res, next) - } - else { + if (!rest.checkPatchOverrideSupport(req, res)) { res.statusMessage = 'Improper request method for updating, please use PATCH to remove keys from this object.' res.status(405) next(res) + return } + controller.patchUnset(req, res, next) }) .all((req, res, next) => { res.statusMessage = 'Improper request method for updating, please use PATCH to remove keys from this object.' diff --git a/routes/patchUpdate.js b/routes/patchUpdate.js index 5df088bf..91db46e0 100644 --- a/routes/patchUpdate.js +++ b/routes/patchUpdate.js @@ -9,14 +9,13 @@ import auth from '../auth/index.js' router.route('/') .patch(auth.checkJwt, controller.patchUpdate) .post(auth.checkJwt, (req, res, next) => { - if (rest.checkPatchOverrideSupport(req, res)) { - controller.patchUpdate(req, res, next) - } - else { + if (!rest.checkPatchOverrideSupport(req, res)) { res.statusMessage = 'Improper request method for updating, please use PATCH to alter the existing keys this object.' res.status(405) next(res) + return } + controller.patchUpdate(req, res, next) }) .all((req, res, next) => { res.statusMessage = 'Improper request method for updating, please use PATCH to alter existing keys on this object.' From 8a8ef3aa5bd678ed16e00462eb917d0877b4a501 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 20:19:44 +0000 Subject: [PATCH 3/3] Refactor app.js maintenance mode check to use guard clause Co-authored-by: cubap <1119165+cubap@users.noreply.github.com> --- app.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 7e41fded..77c3f3a6 100644 --- a/app.js +++ b/app.js @@ -72,10 +72,9 @@ app.use(express.static(path.join(__dirname, 'public'))) app.all('*', (req, res, next) => { if(process.env.DOWN === "true"){ res.status(503).json({"message":"RERUM v1 is down for updates or maintenance at this time. We apologize for the inconvenience. Try again later."}) + return } - else{ - next() //pass on to the next app.use - } + next() //pass on to the next app.use }) app.use('/', indexRouter)