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) 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.'