diff --git a/index.html b/index.html index fe85d84..21c16e7 100644 --- a/index.html +++ b/index.html @@ -132,23 +132,22 @@
// app.js
 app.get('/', function (req, res) {
-  var response = {}
-  response["current_user"] = {
-    username: "@" + req.user.username,
-    firstname: req.user.name.split(' ')[0],
-    lastname: req.user.name.split(' ')[1]
-  }
-  var transformed_posts = db.posts.map(function(post){
-    return {
-      slug: post.slug
-      permalink: "https://blahblahblah.blahblah/" + post.slug,
-      post_title: post.title,
-      post_content: post.content
-    }
-  })
-  response["posts"] = transformed_posts
-  res.json(response)
-})
+  res.json({
+    current_user: {
+      username: "@" + req.user.username,
+      firstname: req.user.name.split(' ')[0],
+      lastname: req.user.name.split(' ')[1]
+    },
+    posts: db.posts.map((post) => {
+      return {
+        slug: post.slug,
+        permalink: "https://blahblahblah.blahblah/" + post.slug,
+        post_title: post.title,
+        post_content: post.content
+      };
+    }),
+  });
+});
 

New way: Declarative approach with st.js

@@ -314,4 +313,4 @@ } }) .root(); -

\ No newline at end of file +