diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-22 07:11:26 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-22 07:11:26 +0100 |
| commit | fa4ed0f3b1ce5decfc6ee59d38e63e78a7793de4 (patch) | |
| tree | 74658c754cbdff432aa8dc8b4f3521c993993c45 /bucky/app/bucky.js | |
| parent | 1a67f6f262364ee4fed0c1538ef2f41d772bf1b1 (diff) | |
new keyword form
Diffstat (limited to 'bucky/app/bucky.js')
| -rw-r--r-- | bucky/app/bucky.js | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index dbb980d..cd70790 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -94,9 +94,9 @@ var bucky = module.exports = { next() }) }, - + /* DETAILS */ - + ensureThread: function (req, res, next){ var id = req.params.id.replace(/\D/g, "") if (! id) { @@ -253,7 +253,7 @@ var bucky = module.exports = { res.sendStatus(500) }) }, - + /* KEYWORDS */ ensureKeyword: function (req, res, next){ @@ -296,7 +296,24 @@ var bucky = module.exports = { next() }) }, - + createKeyword: function (req, res, next){ + if (! req.body.keyword || ! req.body.keyword.length) { + res.json({ error: "no keyword" }) + return + } + var data = { + keyword: req.body.keyword, + owner: req.user.get('username'), + createdate: util.now(), + public: 1, + color: req.body.color || 'blue', + } + db.createKeyword(data).then(function(keyword){ + res.keyword = keyword + next() + }) + }, + /* POSTING */ verifyFilesOrComment: function (req, res, next){ @@ -308,9 +325,9 @@ var bucky = module.exports = { } next() }, - + /* COMMENTS */ - + ensureComment: function (req, res, next){ var id = req.params.id.replace(/\D/g, "") if (! id) { @@ -442,7 +459,7 @@ var bucky = module.exports = { /* PROFILE / USER */ - + ensureUser: function (req, res, next){ var username = util.sanitizeName(req.params.username) if (! username) { |
