Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit 7530dc8

Browse files
authored
Merge pull request #50 from SpringRoll/bugfix/remove-method-override
Bugfix/remove method override
2 parents 2848c7b + b467bd6 commit 7530dc8

File tree

4 files changed

+12
-29
lines changed

4 files changed

+12
-29
lines changed

app/routes/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module.exports = function(app)
33
const access = require('../helpers/access');
44
const marky = require("marky-markdown");
55
const Config = require('../models/config');
6-
const methodOverride = require('method-override');
76

87
// Add the user to whatever template
98
app.use(function(req, res, next)
@@ -38,17 +37,23 @@ module.exports = function(app)
3837
});
3938
});
4039

41-
app.use(methodOverride(function (req, res) {
40+
app.use(function (req, res, next) {
4241
const route = req.originalUrl.startsWith('/games') || req.originalUrl.startsWith('/archive') || req.originalUrl.startsWith('/releases');
4342
const contents = req.body && typeof req.body === 'object' && 'action' in req.body;
43+
// if fails cases, can just pass through w/ no change
4444
if (route && contents) {
45+
// Map RESTORE keyword to PATCH action, w/ isArchived flag change
4546
if (req.body.action === 'RESTORE') {
4647
req.body.isArchived = false;
47-
return 'PATCH';
48+
req.method = 'PATCH';
49+
}
50+
// Set POST to PATCH / DELETE based on value in form
51+
else {
52+
req.method = req.body.action;
4853
}
49-
return req.body.action;
5054
}
51-
}));
55+
next();
56+
});
5257

5358
// Site pages
5459
app.use('/', require('./home'));

app/views/games/releases.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ append gameContent
8181
a(href="#{game.repository}/browse?at=refs/heads/#{release.branch.replace('origin/', '')}" data-toggle="tooltip" title="View Branch")=' '+release.branch
8282

8383
.help-block.updated
84-
span Updated
84+
span Updated  
8585
span=moment(release.updated).fromNow()
8686
if release.updatedBy
8787
| by #{release.updatedBy.name}

npm-shrinkwrap.json

Lines changed: 1 addition & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"jade": "^1.9.2",
3030
"jquery": "^3.0.0",
3131
"marky-markdown": "^12.0.0",
32-
"method-override": "3.0.0",
3332
"moment": "^2.9.0",
3433
"mongoose": "~4.0.4",
3534
"mongoose-deep-populate": "^1.0.1",

0 commit comments

Comments
 (0)