diff options
Diffstat (limited to 'bucky/app/bucky.js')
| -rw-r--r-- | bucky/app/bucky.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index d1aad4d..876a769 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -71,6 +71,23 @@ var bucky = module.exports = { next() }) }, + createThread: function (req, res, next){ + if (! req.body.title || ! req.body.title.length) { + res.json({ error: "no title" }) + return + } + var data = { + thread: res.thread.get('id'), + parent_id: req.body.parent_id || -1, + username: req.user.get('username'), + date: util.now(), + comment: req.body.comment, + } + db.createComment(data).then(function(comment){ + res.comment = comment + next() + }) + }, /* DETAILS */ @@ -125,6 +142,15 @@ var bucky = module.exports = { next() }) }, + ensureKeywords: function (req, res, next){ + db.getKeywords().then(function(k){ + if (! k) { + return res.sendStatus(404) + } + res.keywords = k + next() + }) + }, ensureThreadsForKeyword: function (req, res, next){ var keyword = req.params.keyword if (! keyword) { |
