This repository was archived by the owner on Apr 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff 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' ) ) ;
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments