]> git.r.bdr.sh - rbdr/dasein/blobdiff - lib/dasein.js
🔧 Update version in package.json
[rbdr/dasein] / lib / dasein.js
index 3a537bd8ccdf9d11b33e0d888bc269cfa5b8b838..5b8486a09806a132be9ae8d262b39c331a677313 100644 (file)
@@ -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() {