summaryrefslogtreecommitdiff
path: root/server/lib/api
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-08-18 21:25:28 -0400
committerJules Laplace <jules@okfoc.us>2015-08-18 21:25:28 -0400
commitd9ecfddd7ba63d3cf94b29053476d1d11118d38e (patch)
tree55e759395068e4e21125e140d2a23f1833801ffb /server/lib/api
parent62a8127787c1ed2f0ae420722be9327e421633bd (diff)
saving blueprints
Diffstat (limited to 'server/lib/api')
-rw-r--r--server/lib/api/blueprint.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/server/lib/api/blueprint.js b/server/lib/api/blueprint.js
index 7319055..e581d8f 100644
--- a/server/lib/api/blueprint.js
+++ b/server/lib/api/blueprint.js
@@ -81,6 +81,26 @@ var blueprint = {
})
})
},
+
+ update: function(req, res){
+ var _id = req.body._id
+ var data = util.cleanQuery(req.body)
+ if (! _id) { return res.json({ error: 404 }) }
+ Blueprint.findOne({ _id: _id }, function(err, doc){
+ if (! doc) { return res.json({ error: 404 }) }
+ if (String(doc.user_id) !== String(req.user._id)) { return res.json({ error: 404 }) }
+
+ doc.name = util.sanitize(data.name)
+ doc.slug = util.slugify(data.name)
+ doc.shapes = JSON.parse(data.shapes)
+ doc.startPosition = JSON.parse(data.startPosition)
+
+ doc.save(function(err, rec){
+ if (err || ! rec) { return res.json({ error: err }) }
+ res.json(rec)
+ })
+ })
+ },
destroy: function(req, res){
var _id = util.sanitize(req.body._id)