-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor DELETE operations into separate handlers AND add POST-to-DEL…
…ETE mapping to mws-server
- Loading branch information
1 parent
1d3209e
commit e59eba9
Showing
6 changed files
with
178 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-bag.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*\ | ||
title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/delete-bag.js | ||
type: application/javascript | ||
module-type: mws-route | ||
DELETE /bags/:bag-name | ||
\*/ | ||
(function() { | ||
|
||
/*jslint node: true, browser: true */ | ||
/*global $tw: false */ | ||
"use strict"; | ||
|
||
exports.method = "DELETE"; | ||
|
||
exports.path = /^\/bags\/([^\/]+)$/; | ||
|
||
exports.csrfDisable = true; | ||
|
||
exports.useACL = true; | ||
|
||
exports.entityName = "bag" | ||
|
||
exports.handler = function(request,response,state) { | ||
const bagName = state.params[0]; | ||
if(bagName) { | ||
const result = $tw.mws.store.deleteBag(bagName); | ||
if(!result) { | ||
state.sendResponse(302,{ | ||
"Content-Type": "text/plain", | ||
"Location": "/" | ||
}); | ||
} else { | ||
state.sendResponse(400,{ | ||
"Content-Type": "text/plain" | ||
}, | ||
result.message, | ||
"utf8"); | ||
} | ||
} else { | ||
state.sendResponse(400,{ | ||
"Content-Type": "text/plain" | ||
}); | ||
} | ||
}; | ||
|
||
}()); |
48 changes: 48 additions & 0 deletions
48
plugins/tiddlywiki/multiwikiserver/modules/routes/handlers/delete-recipe.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*\ | ||
title: $:/plugins/tiddlywiki/multiwikiserver/routes/handlers/delete-recipe.js | ||
type: application/javascript | ||
module-type: mws-route | ||
DELETE /recipes/:recipe-name | ||
\*/ | ||
(function() { | ||
|
||
/*jslint node: true, browser: true */ | ||
/*global $tw: false */ | ||
"use strict"; | ||
|
||
exports.method = "DELETE"; | ||
|
||
exports.path = /^\/recipes\/([^\/]+)$/; | ||
|
||
exports.csrfDisable = true; | ||
|
||
exports.useACL = true; | ||
|
||
exports.entityName = "recipe" | ||
|
||
exports.handler = function(request,response,state) { | ||
const recipeName = state.params[0]; | ||
if(recipeName) { | ||
const result = $tw.mws.store.deleteRecipe(recipeName); | ||
if(!result) { | ||
state.sendResponse(302,{ | ||
"Content-Type": "text/plain", | ||
"Location": "/" | ||
}); | ||
} else { | ||
state.sendResponse(400,{ | ||
"Content-Type": "text/plain" | ||
}, | ||
result.message, | ||
"utf8"); | ||
} | ||
} else { | ||
state.sendResponse(400,{ | ||
"Content-Type": "text/plain" | ||
}); | ||
} | ||
}; | ||
|
||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters