Add a controller for the removal of draggables

This commit is contained in:
Paul van Tilburg 2012-01-15 17:14:18 +01:00
parent 87a9aa2f27
commit f987f79581

View file

@ -142,6 +142,24 @@ app.post('/draggables/:id', function(req, res) {
new_pos.left = req.body.left;
});
// Draggable removal controller: removes the specific draggable from the
// database.
app.del('/draggables/:id', function(req, res) {
var file_id = req.params.id;
console.log("Hello?");
fs.unlink("public/upload/" + file_id, function(err) {
if (err) {
console.log("Something went wrong while deleting " +
file_id + ": " + err);
res.send(err);
throw err;
}
delete draggables[file_id];
console.log("Deleted draggable " + file_id);
res.send(true);
});
});
// Signal handling.
process.on('SIGINT', function() { db.save(draggables); process.exit(0); });
process.on('SIGTERM', function() { db.save(draggables); process.exit(0); });