forked from TiddlyWiki/TiddlyWiki5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete-bag.js
48 lines (38 loc) · 856 Bytes
/
delete-bag.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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"
});
}
};
}());