{"action":"created","comment":{"url":"https://api.github.com/repos/andela-efortune/efortune/pulls/comments/97532075","pull_request_review_id":18142925,"id":97532075,"diff_hunk":"@@ -0,0 +1,123 @@\n+const express = require('express');\n+const bodyParser = require('body-parser');\n+const morgan = require('morgan');\n+const mailer = require('nodemailer');\n+const hbs = require('express-handlebars');\n+const path = require('path');\n+const validator = require('express-validator');\n+\n+/**\n+ * Express app instance\n+ */\n+const app = express();\n+\n+/**\n+ * Use morgan to log requests details to console\n+ */\n+app.use(morgan('combined'));\n+\n+/**\n+ * Use bodyParser to enhance POST requests information\n+ */\n+app.use(bodyParser.urlencoded({\n+  extended: true\n+}));\n+app.use(bodyParser.json());\n+\n+// Use validator right before the body get's parsed\n+app.use(validator());\n+\n+/**\n+ * Use express static to capture all view files in a single\n+ * directory and set up the handlebars view engine.\n+ */\n+app.engine('html', hbs({\n+  extname: '.html'\n+}));\n+app.set('views', path.join(__dirname, '/views'));\n+app.set('view engine', 'html');\n+app.use(express.static(path.join(__dirname + '/views/static')));\n+const router = express.Router();\n+\n+// Condition variables that determines what should be sent to the user\n+let error, errMsg, success;\n+\n+/**\n+ * On request of this route (/) serve my index page please, Thanks.\n+ */\n+router.get('/', (req, res) => {\n+  res.render('index', {\n+    error,\n+    errMsg,\n+    success\n+  });\n+\n+  // Reset error and success condition\n+  error = null;\n+  errMsg = null;\n+  success = null;\n+});\n+\n+/**\n+ * Post contact form data to this endpoint\n+ * while using nodemailer transporter.\n+ */\n+router.post('/contact', (req, res) => {\n+  // Validate data\n+  req.checkBody('name', 'Name cannot be empty').notEmpty();\n+  req.checkBody('email', 'Invalid email').notEmpty().isEmail();\n+  req.checkBody('subject', 'Subject cannot be empty').notEmpty();\n+  req.checkBody('message', 'Message cannot be empty').notEmpty();\n+\n+  // Enforce validation.\n+  const validationError = req.validationErrors();\n+\n+  if (validationError) {\n+    error = true;\n+    errMsg = validationError;\n+    res.redirect('/#contact');\n+  }\n+\n+  const transporter = mailer.createTransport({\n+    service: 'Gmail',\n+    auth: {\n+      user: process.env.EMAIL,\n+      pass: process.env.PASS,\n+    }\n+  });\n+\n+  // Mail options with the format of the email\n+  const mailOptions = {\n+    from: 'Fortune Ekeruo <' + process.env.EMAIL + '>',\n+    to: process.env.EMAIL,\n+    subject: 'Someone is trying to contact me from my personal website',\n+    text: 'Information decrypted... Name: ' + req.body.name + '\\nEmail: ' +\n+      req.body.email + '\\nPhone: ' + req.body.phone + '\\nSubject: ' +\n+      req.body.subject + '\\nMessage: ' + req.body.message,\n+    html: '<p>Information decrypted...</p> <ul><li>Name: ' + req.body.name + '</li><li>Email: ' +\n+      req.body.email + '</li><li>Phone: ' + req.body.phone + '</li><li>Subject: ' +\n+      req.body.subject + '</li><li>Message: ' + req.body.message + '</li></ul>',\n+  };\n+\n+  // Shoot me the email and return an error or success condition\n+  transporter.sendMail(mailOptions, (err, info) => {\n+    if (err) {\n+      error = true;\n+      res.redirect('/#contact');\n+    } else {\n+      // Message sent\n+      success = true;\n+      res.redirect('/#contact');","path":"server.js","position":110,"original_position":110,"commit_id":"93b62c197b05954957ad8486184f3bb124ca0639","original_commit_id":"93b62c197b05954957ad8486184f3bb124ca0639","user":{"login":"azemoh","id":11008869,"avatar_url":"https://avatars.githubusercontent.com/u/11008869?v=3","gravatar_id":"","url":"https://api.github.com/users/azemoh","html_url":"https://github.com/azemoh","followers_url":"https://api.github.com/users/azemoh/followers","following_url":"https://api.github.com/users/azemoh/following{/other_user}","gists_url":"https://api.github.com/users/azemoh/gists{/gist_id}","starred_url":"https://api.github.com/users/azemoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azemoh/subscriptions","organizations_url":"https://api.github.com/users/azemoh/orgs","repos_url":"https://api.github.com/users/azemoh/repos","events_url":"https://api.github.com/users/azemoh/events{/privacy}","received_events_url":"https://api.github.com/users/azemoh/received_events","type":"User","site_admin":false},"body":"Can you move `res.redirect('/#contact');` out of the `if/else` block since it is being called regardless.","created_at":"2017-01-24T12:05:51Z","updated_at":"2017-01-24T12:11:32Z","html_url":"https://github.com/andela-efortune/efortune/pull/10#discussion_r97532075","pull_request_url":"https://api.github.com/repos/andela-efortune/efortune/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/andela-efortune/efortune/pulls/comments/97532075"},"html":{"href":"https://github.com/andela-efortune/efortune/pull/10#discussion_r97532075"},"pull_request":{"href":"https://api.github.com/repos/andela-efortune/efortune/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/andela-efortune/efortune/pulls/10","id":101226685,"html_url":"https://github.com/andela-efortune/efortune/pull/10","diff_url":"https://github.com/andela-efortune/efortune/pull/10.diff","patch_url":"https://github.com/andela-efortune/efortune/pull/10.patch","issue_url":"https://api.github.com/repos/andela-efortune/efortune/issues/10","number":10,"state":"open","locked":false,"title":"About, Portfolio and Connect sections","user":{"login":"andela-efortune","id":12124618,"avatar_url":"https://avatars.githubusercontent.com/u/12124618?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-efortune","html_url":"https://github.com/andela-efortune","followers_url":"https://api.github.com/users/andela-efortune/followers","following_url":"https://api.github.com/users/andela-efortune/following{/other_user}","gists_url":"https://api.github.com/users/andela-efortune/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-efortune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-efortune/subscriptions","organizations_url":"https://api.github.com/users/andela-efortune/orgs","repos_url":"https://api.github.com/users/andela-efortune/repos","events_url":"https://api.github.com/users/andela-efortune/events{/privacy}","received_events_url":"https://api.github.com/users/andela-efortune/received_events","type":"User","site_admin":false},"body":"### What this PR does\r\nIt adds an about section that talks about me\r\nIt adds a portfolio section that will showcase a list of projects I have done.\r\nIt adds a connect section that allows users to connect with me via social media or send me an email via a contact form.","created_at":"2017-01-12T09:54:00Z","updated_at":"2017-01-24T12:11:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05d355286be2e8db8e5c7e71ef240637a3d448ca","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela-efortune/efortune/pulls/10/commits","review_comments_url":"https://api.github.com/repos/andela-efortune/efortune/pulls/10/comments","review_comment_url":"https://api.github.com/repos/andela-efortune/efortune/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela-efortune/efortune/issues/10/comments","statuses_url":"https://api.github.com/repos/andela-efortune/efortune/statuses/93b62c197b05954957ad8486184f3bb124ca0639","head":{"label":"andela-efortune:develop","ref":"develop","sha":"93b62c197b05954957ad8486184f3bb124ca0639","user":{"login":"andela-efortune","id":12124618,"avatar_url":"https://avatars.githubusercontent.com/u/12124618?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-efortune","html_url":"https://github.com/andela-efortune","followers_url":"https://api.github.com/users/andela-efortune/followers","following_url":"https://api.github.com/users/andela-efortune/following{/other_user}","gists_url":"https://api.github.com/users/andela-efortune/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-efortune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-efortune/subscriptions","organizations_url":"https://api.github.com/users/andela-efortune/orgs","repos_url":"https://api.github.com/users/andela-efortune/repos","events_url":"https://api.github.com/users/andela-efortune/events{/privacy}","received_events_url":"https://api.github.com/users/andela-efortune/received_events","type":"User","site_admin":false},"repo":{"id":74390254,"name":"efortune","full_name":"andela-efortune/efortune","owner":{"login":"andela-efortune","id":12124618,"avatar_url":"https://avatars.githubusercontent.com/u/12124618?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-efortune","html_url":"https://github.com/andela-efortune","followers_url":"https://api.github.com/users/andela-efortune/followers","following_url":"https://api.github.com/users/andela-efortune/following{/other_user}","gists_url":"https://api.github.com/users/andela-efortune/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-efortune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-efortune/subscriptions","organizations_url":"https://api.github.com/users/andela-efortune/orgs","repos_url":"https://api.github.com/users/andela-efortune/repos","events_url":"https://api.github.com/users/andela-efortune/events{/privacy}","received_events_url":"https://api.github.com/users/andela-efortune/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-efortune/efortune","description":"My personal website: A world of love, kindness, goodness and Godliness ","fork":false,"url":"https://api.github.com/repos/andela-efortune/efortune","forks_url":"https://api.github.com/repos/andela-efortune/efortune/forks","keys_url":"https://api.github.com/repos/andela-efortune/efortune/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-efortune/efortune/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-efortune/efortune/teams","hooks_url":"https://api.github.com/repos/andela-efortune/efortune/hooks","issue_events_url":"https://api.github.com/repos/andela-efortune/efortune/issues/events{/number}","events_url":"https://api.github.com/repos/andela-efortune/efortune/events","assignees_url":"https://api.github.com/repos/andela-efortune/efortune/assignees{/user}","branches_url":"https://api.github.com/repos/andela-efortune/efortune/branches{/branch}","tags_url":"https://api.github.com/repos/andela-efortune/efortune/tags","blobs_url":"https://api.github.com/repos/andela-efortune/efortune/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-efortune/efortune/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-efortune/efortune/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-efortune/efortune/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-efortune/efortune/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-efortune/efortune/languages","stargazers_url":"https://api.github.com/repos/andela-efortune/efortune/stargazers","contributors_url":"https://api.github.com/repos/andela-efortune/efortune/contributors","subscribers_url":"https://api.github.com/repos/andela-efortune/efortune/subscribers","subscription_url":"https://api.github.com/repos/andela-efortune/efortune/subscription","commits_url":"https://api.github.com/repos/andela-efortune/efortune/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-efortune/efortune/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-efortune/efortune/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-efortune/efortune/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-efortune/efortune/contents/{+path}","compare_url":"https://api.github.com/repos/andela-efortune/efortune/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-efortune/efortune/merges","archive_url":"https://api.github.com/repos/andela-efortune/efortune/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-efortune/efortune/downloads","issues_url":"https://api.github.com/repos/andela-efortune/efortune/issues{/number}","pulls_url":"https://api.github.com/repos/andela-efortune/efortune/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-efortune/efortune/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-efortune/efortune/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-efortune/efortune/labels{/name}","releases_url":"https://api.github.com/repos/andela-efortune/efortune/releases{/id}","deployments_url":"https://api.github.com/repos/andela-efortune/efortune/deployments","created_at":"2016-11-21T17:52:53Z","updated_at":"2017-01-11T12:19:21Z","pushed_at":"2017-01-20T11:52:24Z","git_url":"git://github.com/andela-efortune/efortune.git","ssh_url":"git@github.com:andela-efortune/efortune.git","clone_url":"https://github.com/andela-efortune/efortune.git","svn_url":"https://github.com/andela-efortune/efortune","homepage":"","size":986,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"andela-efortune:master","ref":"master","sha":"d20e078fcd10f2e0600804c6df7d437d0c8dd978","user":{"login":"andela-efortune","id":12124618,"avatar_url":"https://avatars.githubusercontent.com/u/12124618?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-efortune","html_url":"https://github.com/andela-efortune","followers_url":"https://api.github.com/users/andela-efortune/followers","following_url":"https://api.github.com/users/andela-efortune/following{/other_user}","gists_url":"https://api.github.com/users/andela-efortune/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-efortune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-efortune/subscriptions","organizations_url":"https://api.github.com/users/andela-efortune/orgs","repos_url":"https://api.github.com/users/andela-efortune/repos","events_url":"https://api.github.com/users/andela-efortune/events{/privacy}","received_events_url":"https://api.github.com/users/andela-efortune/received_events","type":"User","site_admin":false},"repo":{"id":74390254,"name":"efortune","full_name":"andela-efortune/efortune","owner":{"login":"andela-efortune","id":12124618,"avatar_url":"https://avatars.githubusercontent.com/u/12124618?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-efortune","html_url":"https://github.com/andela-efortune","followers_url":"https://api.github.com/users/andela-efortune/followers","following_url":"https://api.github.com/users/andela-efortune/following{/other_user}","gists_url":"https://api.github.com/users/andela-efortune/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-efortune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-efortune/subscriptions","organizations_url":"https://api.github.com/users/andela-efortune/orgs","repos_url":"https://api.github.com/users/andela-efortune/repos","events_url":"https://api.github.com/users/andela-efortune/events{/privacy}","received_events_url":"https://api.github.com/users/andela-efortune/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-efortune/efortune","description":"My personal website: A world of love, kindness, goodness and Godliness ","fork":false,"url":"https://api.github.com/repos/andela-efortune/efortune","forks_url":"https://api.github.com/repos/andela-efortune/efortune/forks","keys_url":"https://api.github.com/repos/andela-efortune/efortune/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-efortune/efortune/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-efortune/efortune/teams","hooks_url":"https://api.github.com/repos/andela-efortune/efortune/hooks","issue_events_url":"https://api.github.com/repos/andela-efortune/efortune/issues/events{/number}","events_url":"https://api.github.com/repos/andela-efortune/efortune/events","assignees_url":"https://api.github.com/repos/andela-efortune/efortune/assignees{/user}","branches_url":"https://api.github.com/repos/andela-efortune/efortune/branches{/branch}","tags_url":"https://api.github.com/repos/andela-efortune/efortune/tags","blobs_url":"https://api.github.com/repos/andela-efortune/efortune/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-efortune/efortune/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-efortune/efortune/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-efortune/efortune/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-efortune/efortune/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-efortune/efortune/languages","stargazers_url":"https://api.github.com/repos/andela-efortune/efortune/stargazers","contributors_url":"https://api.github.com/repos/andela-efortune/efortune/contributors","subscribers_url":"https://api.github.com/repos/andela-efortune/efortune/subscribers","subscription_url":"https://api.github.com/repos/andela-efortune/efortune/subscription","commits_url":"https://api.github.com/repos/andela-efortune/efortune/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-efortune/efortune/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-efortune/efortune/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-efortune/efortune/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-efortune/efortune/contents/{+path}","compare_url":"https://api.github.com/repos/andela-efortune/efortune/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-efortune/efortune/merges","archive_url":"https://api.github.com/repos/andela-efortune/efortune/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-efortune/efortune/downloads","issues_url":"https://api.github.com/repos/andela-efortune/efortune/issues{/number}","pulls_url":"https://api.github.com/repos/andela-efortune/efortune/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-efortune/efortune/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-efortune/efortune/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-efortune/efortune/labels{/name}","releases_url":"https://api.github.com/repos/andela-efortune/efortune/releases{/id}","deployments_url":"https://api.github.com/repos/andela-efortune/efortune/deployments","created_at":"2016-11-21T17:52:53Z","updated_at":"2017-01-11T12:19:21Z","pushed_at":"2017-01-20T11:52:24Z","git_url":"git://github.com/andela-efortune/efortune.git","ssh_url":"git@github.com:andela-efortune/efortune.git","clone_url":"https://github.com/andela-efortune/efortune.git","svn_url":"https://github.com/andela-efortune/efortune","homepage":"","size":986,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andela-efortune/efortune/pulls/10"},"html":{"href":"https://github.com/andela-efortune/efortune/pull/10"},"issue":{"href":"https://api.github.com/repos/andela-efortune/efortune/issues/10"},"comments":{"href":"https://api.github.com/repos/andela-efortune/efortune/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/andela-efortune/efortune/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/andela-efortune/efortune/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela-efortune/efortune/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/andela-efortune/efortune/statuses/93b62c197b05954957ad8486184f3bb124ca0639"}}}}
{"actor":{"display_login":"azemoh"}}