diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-09-07 14:29:23 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-09-07 14:29:23 -0400 |
| commit | 43265c66f757222bbe8fefb670300c0a3d3b51bf (patch) | |
| tree | 175240fb3041b3f6cd60b0c3a33d391493941542 /lib/bucky.js | |
| parent | ff6954f49a4006095ddcf85289679fc515a38f82 (diff) | |
stub middleware
Diffstat (limited to 'lib/bucky.js')
| -rw-r--r-- | lib/bucky.js | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/lib/bucky.js b/lib/bucky.js index 997d680..742f74d 100644 --- a/lib/bucky.js +++ b/lib/bucky.js @@ -70,6 +70,9 @@ var bucky = module.exports = { ensureThread: function (req, res, next){ var id = req.params.id.replace(/\D/g, "") + if (! id) { + return res.sendStatus(404) + } db.getThread(id).then(function(thread){ if (thread) { res.thread = thread @@ -106,7 +109,7 @@ var bucky = module.exports = { ensureKeyword: function (req, res, next){ var keyword = req.params.keyword if (! keyword) { - res.sendStatus(404) + return res.sendStatus(404) } db.getKeyword(keyword).then(function(k){ if (! k) { @@ -128,5 +131,32 @@ var bucky = module.exports = { next() }) }, + + /* MAIL */ + ensureMailbox: function (req, res, next){ + var box = req.params.box + if (! box) { + res.sendStatus(404) + } + db.getMailbox(req.user.username, box).then(function(box){ + if (! box) { + return res.sendStatus(404) + } + next() + }) + }, + ensureMailboxCounts: function (req, res, next){ + db.getMailboxes(req.user.username).then(function(boxes){ + res.boxes = boxes + next() + }) + }, + ensureMessages: function (req, res, next){ + // todo: define offset + db.getMessages(req.user.username, req.params.box, 50, 0).then(function(messages){ + res.messages = messages + next() + }) + }, }
\ No newline at end of file |
