diff options
| author | Rubén Beltrán del Río <ben@nsovocal.com> | 2017-01-31 00:49:26 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-31 00:49:26 -0600 |
| commit | 9b1f50fefe021578113b8f5935084fe4fed110b2 (patch) | |
| tree | 98805583b7c5041f16b195de823c5524f4de7672 /lib/dasein.js | |
| parent | a6ccda0fbc4df683f9568d85eb22b21684d2a0bd (diff) | |
Add Comments (#4)
* Preserve whitespace in posts
* Create comments handler
* Use comments handler
* Update paw
* Add comment components
* Style comments
* Remove unnecessary code from app
* Fix linter warning
* Add key to handle children (thx @javierbyte)
* Add toggling to the form
* Return all keys always
* Correct missing semicolons
* Restore redirect
* Render posts conditionally
* Set poll time to 1s
* Set post frequency to 2s
* Add polling to comments
* Correct typo in error logging
* Clear intervals and reduce polling
* Stops polling if it's being destroyed
* Update changelog
Diffstat (limited to 'lib/dasein.js')
| -rw-r--r-- | lib/dasein.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/dasein.js b/lib/dasein.js index 3a537bd..5b8486a 100644 --- a/lib/dasein.js +++ b/lib/dasein.js @@ -10,6 +10,7 @@ const Path = require('path'); const AuthHandler = require('./handlers/auth'); const PostsHandler = require('./handlers/posts'); +const CommentsHandler = require('./handlers/comments'); const internals = {}; @@ -90,6 +91,7 @@ module.exports = internals.Dasein = class Dasein { this._initializeAuthRoutes(); this._initializePostsRoutes(); + this._initializeCommentsRoutes(); this._app.use(function * () { @@ -125,6 +127,18 @@ module.exports = internals.Dasein = class Dasein { } + // Initialize routes for comments + + _initializeCommentsRoutes() { + + const commentsHandler = new CommentsHandler({ + ttl: this.ttl, + redis: this.redis + }); + this._app.use(KoaRoute.get('/api/posts/:postId/comments', commentsHandler.findAll())); + this._app.use(KoaRoute.post('/api/posts/:postId/comments', commentsHandler.create())); + } + // Starts listening _startServer() { |