Added delete feature for nodes.
This commit is contained in:
parent
39e7af6238
commit
79aadc85c2
20 changed files with 300 additions and 20 deletions
server/services
|
@ -101,6 +101,23 @@ angular.module('ffffng')
|
|||
return callback(null, token, node);
|
||||
}
|
||||
|
||||
function deleteNodeFile(token, callback) {
|
||||
var files = findNodeFiles('*@*@*@' + token);
|
||||
if (files.length !== 1) {
|
||||
return callback({data: 'Node not found.', type: ErrorTypes.notFound});
|
||||
}
|
||||
|
||||
try {
|
||||
fs.unlinkSync(files[0]);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
return callback({data: 'Could not delete node.', type: ErrorTypes.internalError});
|
||||
}
|
||||
|
||||
return callback(null);
|
||||
}
|
||||
|
||||
function parseNodeFile(file, callback) {
|
||||
var lines = fs.readFileSync(file).toString();
|
||||
|
||||
|
@ -140,6 +157,10 @@ angular.module('ffffng')
|
|||
writeNodeFile(true, token, node, callback);
|
||||
},
|
||||
|
||||
deleteNode: function (token, callback) {
|
||||
deleteNodeFile(token, callback);
|
||||
},
|
||||
|
||||
getNodeData: function (token, callback) {
|
||||
var files = findNodeFiles('*@*@*@' + token);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue