From 9e6b80c0321ba1fbe1c824083acbeeac7b7b94d4 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 10 Dec 2017 07:02:47 +0100 Subject: post form and other stuff --- bucky/app/bucky.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'bucky/app/bucky.js') 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) { -- cgit v1.2.3-70-g09d2