diff options
Diffstat (limited to 'bucky/app')
| -rw-r--r-- | bucky/app/api.js | 8 | ||||
| -rw-r--r-- | bucky/app/bucky.js | 15 | ||||
| -rw-r--r-- | bucky/app/pages.js | 7 |
3 files changed, 30 insertions, 0 deletions
diff --git a/bucky/app/api.js b/bucky/app/api.js index b4231e7..a6aa83f 100644 --- a/bucky/app/api.js +++ b/bucky/app/api.js @@ -34,6 +34,12 @@ function route (app){ function(req, res){ res.json(util.sanitizeUser(res.user)) }) + app.get("/api/users", + middleware.ensureAuthenticated, + bucky.ensureUserlist, + function(req, res) { + res.json(res.users) + }) app.get("/api/profile/:username", middleware.ensureAuthenticated, bucky.ensureUser, @@ -259,9 +265,11 @@ function route (app){ middleware.ensureAuthenticated, bucky.ensureKeywords, bucky.ensureThreadGroups, + bucky.ensureLatestKeywordThreads, function(req, res){ res.json({ keywords: res.keywords, + threads: res.threads, threadGroups: res.threadGroups, }) }) diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index 3824c5e..8ff0b15 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -296,6 +296,12 @@ var bucky = module.exports = { next() }) }, + ensureLatestKeywordThreads: function (req, res, next){ + db.getLatestKeywordThreads().then(function(threads){ + res.threads = threads + next() + }) + }, ensureThreadGroups: function (req, res, next){ db.getThreadGroups().then(function(threadGroups){ res.threadGroups = threadGroups @@ -564,6 +570,15 @@ var bucky = module.exports = { } }) }, + ensureUserlist: function (req, res, next){ + db.getUsers().then(function(users){ + if (! users) { + return res.sendStatus(404) + } + res.users = users + next() + }) + }, sanitizeUser: function(req, res, next) { res.user = util.sanitizeUser(res.user) next() diff --git a/bucky/app/pages.js b/bucky/app/pages.js index 7f666be..b007742 100644 --- a/bucky/app/pages.js +++ b/bucky/app/pages.js @@ -73,6 +73,13 @@ function route (app){ res.render("pages/profile_form", {title: "edit your profile"}) }) + app.get("/users", + middleware.ensureAuthenticated, + function(req, res){ + res.render("pages/users", { + }) + }) + app.get("/search/", middleware.ensureAuthenticated, function(req, res){ |
