{"action":"created","comment":{"url":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/comments/204655846","pull_request_review_id":139770452,"id":204655846,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNDY1NTg0Ng==","diff_hunk":"@@ -0,0 +1,49 @@\n+import model from '../models';\n+\n+const { Todo, User } = model;\n+\n+const Todos = {\n+  create(req, res) {\n+    const { title } = req.body;\n+    Todo.findOrCreate({\n+      where: { title },\n+      defaults: {\n+        title,\n+        userId: req.decoded.id\n+      }\n+    }).spread((todo, created) => {\n+      if (created) {\n+        const createdTodo = todo.get({ plain: true });\n+        const response = { ...createdTodo, success: true, message: 'Todo Added' };\n+        return res.send(response);\n+      }\n+      return res.status(409).send({ success: false, message: 'Todo already exists' });\n+    }).catch(() => {\n+      res.status(500).send({ success: false, message: 'Unexpected error occured' });\n+    });\n+  },\n+\n+  getUserTodos(req, res) {\n+    User.find({ where: { id: req.params.id } }).then((user) => {\n+      Todo.findAll({ where: { userId: user.id } }).then(todo => res.send(todo))\n+        .catch(() => {\n+          res.status(500).send({ success: false, message: 'Unexpected error occured' });\n+        });\n+    });\n+  },\n+\n+  deleteUserTodo(req, res) {\n+    Todo.findById(req.params.id).then((todo) => {\n+      if (todo.userId === req.decoded.id) {\n+        todo.destroy().then(() => res.send({ success: true, message: 'Todo deleted Successfully' }));\n+      } else {\n+        res.status(400).send({ success: false, message: 'You do not have permission to delete this Document' });","path":"controllers/todo.js","position":40,"original_position":40,"commit_id":"9a79a1eee93fdeec5479b1fa44cd6ba0a0cbf136","original_commit_id":"9a79a1eee93fdeec5479b1fa44cd6ba0a0cbf136","user":{"login":"oaboluwarin","id":24937708,"node_id":"MDQ6VXNlcjI0OTM3NzA4","avatar_url":"https://avatars0.githubusercontent.com/u/24937708?v=4","gravatar_id":"","url":"https://api.github.com/users/oaboluwarin","html_url":"https://github.com/oaboluwarin","followers_url":"https://api.github.com/users/oaboluwarin/followers","following_url":"https://api.github.com/users/oaboluwarin/following{/other_user}","gists_url":"https://api.github.com/users/oaboluwarin/gists{/gist_id}","starred_url":"https://api.github.com/users/oaboluwarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oaboluwarin/subscriptions","organizations_url":"https://api.github.com/users/oaboluwarin/orgs","repos_url":"https://api.github.com/users/oaboluwarin/repos","events_url":"https://api.github.com/users/oaboluwarin/events{/privacy}","received_events_url":"https://api.github.com/users/oaboluwarin/received_events","type":"User","site_admin":false},"body":"`You do not have permission to delete this Todo`","created_at":"2018-07-24T07:50:53Z","updated_at":"2018-07-24T07:50:53Z","html_url":"https://github.com/andela-fojuri/todoApp/pull/4#discussion_r204655846","pull_request_url":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/4","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/comments/204655846"},"html":{"href":"https://github.com/andela-fojuri/todoApp/pull/4#discussion_r204655846"},"pull_request":{"href":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/4","id":203348869,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMzQ4ODY5","html_url":"https://github.com/andela-fojuri/todoApp/pull/4","diff_url":"https://github.com/andela-fojuri/todoApp/pull/4.diff","patch_url":"https://github.com/andela-fojuri/todoApp/pull/4.patch","issue_url":"https://api.github.com/repos/andela-fojuri/todoApp/issues/4","number":4,"state":"open","locked":false,"title":"Ft/add Todos Controllers and Routes","user":{"login":"andela-fojuri","id":24938388,"node_id":"MDQ6VXNlcjI0OTM4Mzg4","avatar_url":"https://avatars2.githubusercontent.com/u/24938388?v=4","gravatar_id":"","url":"https://api.github.com/users/andela-fojuri","html_url":"https://github.com/andela-fojuri","followers_url":"https://api.github.com/users/andela-fojuri/followers","following_url":"https://api.github.com/users/andela-fojuri/following{/other_user}","gists_url":"https://api.github.com/users/andela-fojuri/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-fojuri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-fojuri/subscriptions","organizations_url":"https://api.github.com/users/andela-fojuri/orgs","repos_url":"https://api.github.com/users/andela-fojuri/repos","events_url":"https://api.github.com/users/andela-fojuri/events{/privacy}","received_events_url":"https://api.github.com/users/andela-fojuri/received_events","type":"User","site_admin":false},"body":"- Add Todos controllers and routes\r\n- Add updateUser controller","created_at":"2018-07-23T21:27:34Z","updated_at":"2018-07-24T07:50:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fec0b6c760d1cc74bcdb6b3c6664a0d5ef2574d7","assignee":null,"assignees":[],"requested_reviewers":[{"login":"andela-mabdussalam","id":24937734,"node_id":"MDQ6VXNlcjI0OTM3NzM0","avatar_url":"https://avatars3.githubusercontent.com/u/24937734?v=4","gravatar_id":"","url":"https://api.github.com/users/andela-mabdussalam","html_url":"https://github.com/andela-mabdussalam","followers_url":"https://api.github.com/users/andela-mabdussalam/followers","following_url":"https://api.github.com/users/andela-mabdussalam/following{/other_user}","gists_url":"https://api.github.com/users/andela-mabdussalam/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-mabdussalam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-mabdussalam/subscriptions","organizations_url":"https://api.github.com/users/andela-mabdussalam/orgs","repos_url":"https://api.github.com/users/andela-mabdussalam/repos","events_url":"https://api.github.com/users/andela-mabdussalam/events{/privacy}","received_events_url":"https://api.github.com/users/andela-mabdussalam/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/4/commits","review_comments_url":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/4/comments","review_comment_url":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela-fojuri/todoApp/issues/4/comments","statuses_url":"https://api.github.com/repos/andela-fojuri/todoApp/statuses/9a79a1eee93fdeec5479b1fa44cd6ba0a0cbf136","head":{"label":"andela-fojuri:ft/add_todos_controllers","ref":"ft/add_todos_controllers","sha":"9a79a1eee93fdeec5479b1fa44cd6ba0a0cbf136","user":{"login":"andela-fojuri","id":24938388,"node_id":"MDQ6VXNlcjI0OTM4Mzg4","avatar_url":"https://avatars2.githubusercontent.com/u/24938388?v=4","gravatar_id":"","url":"https://api.github.com/users/andela-fojuri","html_url":"https://github.com/andela-fojuri","followers_url":"https://api.github.com/users/andela-fojuri/followers","following_url":"https://api.github.com/users/andela-fojuri/following{/other_user}","gists_url":"https://api.github.com/users/andela-fojuri/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-fojuri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-fojuri/subscriptions","organizations_url":"https://api.github.com/users/andela-fojuri/orgs","repos_url":"https://api.github.com/users/andela-fojuri/repos","events_url":"https://api.github.com/users/andela-fojuri/events{/privacy}","received_events_url":"https://api.github.com/users/andela-fojuri/received_events","type":"User","site_admin":false},"repo":{"id":141279542,"node_id":"MDEwOlJlcG9zaXRvcnkxNDEyNzk1NDI=","name":"todoApp","full_name":"andela-fojuri/todoApp","owner":{"login":"andela-fojuri","id":24938388,"node_id":"MDQ6VXNlcjI0OTM4Mzg4","avatar_url":"https://avatars2.githubusercontent.com/u/24938388?v=4","gravatar_id":"","url":"https://api.github.com/users/andela-fojuri","html_url":"https://github.com/andela-fojuri","followers_url":"https://api.github.com/users/andela-fojuri/followers","following_url":"https://api.github.com/users/andela-fojuri/following{/other_user}","gists_url":"https://api.github.com/users/andela-fojuri/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-fojuri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-fojuri/subscriptions","organizations_url":"https://api.github.com/users/andela-fojuri/orgs","repos_url":"https://api.github.com/users/andela-fojuri/repos","events_url":"https://api.github.com/users/andela-fojuri/events{/privacy}","received_events_url":"https://api.github.com/users/andela-fojuri/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-fojuri/todoApp","description":null,"fork":false,"url":"https://api.github.com/repos/andela-fojuri/todoApp","forks_url":"https://api.github.com/repos/andela-fojuri/todoApp/forks","keys_url":"https://api.github.com/repos/andela-fojuri/todoApp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-fojuri/todoApp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-fojuri/todoApp/teams","hooks_url":"https://api.github.com/repos/andela-fojuri/todoApp/hooks","issue_events_url":"https://api.github.com/repos/andela-fojuri/todoApp/issues/events{/number}","events_url":"https://api.github.com/repos/andela-fojuri/todoApp/events","assignees_url":"https://api.github.com/repos/andela-fojuri/todoApp/assignees{/user}","branches_url":"https://api.github.com/repos/andela-fojuri/todoApp/branches{/branch}","tags_url":"https://api.github.com/repos/andela-fojuri/todoApp/tags","blobs_url":"https://api.github.com/repos/andela-fojuri/todoApp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-fojuri/todoApp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-fojuri/todoApp/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-fojuri/todoApp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-fojuri/todoApp/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-fojuri/todoApp/languages","stargazers_url":"https://api.github.com/repos/andela-fojuri/todoApp/stargazers","contributors_url":"https://api.github.com/repos/andela-fojuri/todoApp/contributors","subscribers_url":"https://api.github.com/repos/andela-fojuri/todoApp/subscribers","subscription_url":"https://api.github.com/repos/andela-fojuri/todoApp/subscription","commits_url":"https://api.github.com/repos/andela-fojuri/todoApp/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-fojuri/todoApp/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-fojuri/todoApp/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-fojuri/todoApp/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-fojuri/todoApp/contents/{+path}","compare_url":"https://api.github.com/repos/andela-fojuri/todoApp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-fojuri/todoApp/merges","archive_url":"https://api.github.com/repos/andela-fojuri/todoApp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-fojuri/todoApp/downloads","issues_url":"https://api.github.com/repos/andela-fojuri/todoApp/issues{/number}","pulls_url":"https://api.github.com/repos/andela-fojuri/todoApp/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-fojuri/todoApp/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-fojuri/todoApp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-fojuri/todoApp/labels{/name}","releases_url":"https://api.github.com/repos/andela-fojuri/todoApp/releases{/id}","deployments_url":"https://api.github.com/repos/andela-fojuri/todoApp/deployments","created_at":"2018-07-17T11:25:30Z","updated_at":"2018-07-23T17:13:44Z","pushed_at":"2018-07-23T21:27:34Z","git_url":"git://github.com/andela-fojuri/todoApp.git","ssh_url":"git@github.com:andela-fojuri/todoApp.git","clone_url":"https://github.com/andela-fojuri/todoApp.git","svn_url":"https://github.com/andela-fojuri/todoApp","homepage":null,"size":93,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"andela-fojuri:develop","ref":"develop","sha":"e89cdfde10a14d2217b542f4a82f0fc9faec54f9","user":{"login":"andela-fojuri","id":24938388,"node_id":"MDQ6VXNlcjI0OTM4Mzg4","avatar_url":"https://avatars2.githubusercontent.com/u/24938388?v=4","gravatar_id":"","url":"https://api.github.com/users/andela-fojuri","html_url":"https://github.com/andela-fojuri","followers_url":"https://api.github.com/users/andela-fojuri/followers","following_url":"https://api.github.com/users/andela-fojuri/following{/other_user}","gists_url":"https://api.github.com/users/andela-fojuri/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-fojuri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-fojuri/subscriptions","organizations_url":"https://api.github.com/users/andela-fojuri/orgs","repos_url":"https://api.github.com/users/andela-fojuri/repos","events_url":"https://api.github.com/users/andela-fojuri/events{/privacy}","received_events_url":"https://api.github.com/users/andela-fojuri/received_events","type":"User","site_admin":false},"repo":{"id":141279542,"node_id":"MDEwOlJlcG9zaXRvcnkxNDEyNzk1NDI=","name":"todoApp","full_name":"andela-fojuri/todoApp","owner":{"login":"andela-fojuri","id":24938388,"node_id":"MDQ6VXNlcjI0OTM4Mzg4","avatar_url":"https://avatars2.githubusercontent.com/u/24938388?v=4","gravatar_id":"","url":"https://api.github.com/users/andela-fojuri","html_url":"https://github.com/andela-fojuri","followers_url":"https://api.github.com/users/andela-fojuri/followers","following_url":"https://api.github.com/users/andela-fojuri/following{/other_user}","gists_url":"https://api.github.com/users/andela-fojuri/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-fojuri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-fojuri/subscriptions","organizations_url":"https://api.github.com/users/andela-fojuri/orgs","repos_url":"https://api.github.com/users/andela-fojuri/repos","events_url":"https://api.github.com/users/andela-fojuri/events{/privacy}","received_events_url":"https://api.github.com/users/andela-fojuri/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-fojuri/todoApp","description":null,"fork":false,"url":"https://api.github.com/repos/andela-fojuri/todoApp","forks_url":"https://api.github.com/repos/andela-fojuri/todoApp/forks","keys_url":"https://api.github.com/repos/andela-fojuri/todoApp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-fojuri/todoApp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-fojuri/todoApp/teams","hooks_url":"https://api.github.com/repos/andela-fojuri/todoApp/hooks","issue_events_url":"https://api.github.com/repos/andela-fojuri/todoApp/issues/events{/number}","events_url":"https://api.github.com/repos/andela-fojuri/todoApp/events","assignees_url":"https://api.github.com/repos/andela-fojuri/todoApp/assignees{/user}","branches_url":"https://api.github.com/repos/andela-fojuri/todoApp/branches{/branch}","tags_url":"https://api.github.com/repos/andela-fojuri/todoApp/tags","blobs_url":"https://api.github.com/repos/andela-fojuri/todoApp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-fojuri/todoApp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-fojuri/todoApp/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-fojuri/todoApp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-fojuri/todoApp/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-fojuri/todoApp/languages","stargazers_url":"https://api.github.com/repos/andela-fojuri/todoApp/stargazers","contributors_url":"https://api.github.com/repos/andela-fojuri/todoApp/contributors","subscribers_url":"https://api.github.com/repos/andela-fojuri/todoApp/subscribers","subscription_url":"https://api.github.com/repos/andela-fojuri/todoApp/subscription","commits_url":"https://api.github.com/repos/andela-fojuri/todoApp/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-fojuri/todoApp/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-fojuri/todoApp/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-fojuri/todoApp/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-fojuri/todoApp/contents/{+path}","compare_url":"https://api.github.com/repos/andela-fojuri/todoApp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-fojuri/todoApp/merges","archive_url":"https://api.github.com/repos/andela-fojuri/todoApp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-fojuri/todoApp/downloads","issues_url":"https://api.github.com/repos/andela-fojuri/todoApp/issues{/number}","pulls_url":"https://api.github.com/repos/andela-fojuri/todoApp/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-fojuri/todoApp/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-fojuri/todoApp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-fojuri/todoApp/labels{/name}","releases_url":"https://api.github.com/repos/andela-fojuri/todoApp/releases{/id}","deployments_url":"https://api.github.com/repos/andela-fojuri/todoApp/deployments","created_at":"2018-07-17T11:25:30Z","updated_at":"2018-07-23T17:13:44Z","pushed_at":"2018-07-23T21:27:34Z","git_url":"git://github.com/andela-fojuri/todoApp.git","ssh_url":"git@github.com:andela-fojuri/todoApp.git","clone_url":"https://github.com/andela-fojuri/todoApp.git","svn_url":"https://github.com/andela-fojuri/todoApp","homepage":null,"size":93,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/4"},"html":{"href":"https://github.com/andela-fojuri/todoApp/pull/4"},"issue":{"href":"https://api.github.com/repos/andela-fojuri/todoApp/issues/4"},"comments":{"href":"https://api.github.com/repos/andela-fojuri/todoApp/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela-fojuri/todoApp/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/andela-fojuri/todoApp/statuses/9a79a1eee93fdeec5479b1fa44cd6ba0a0cbf136"}},"author_association":"OWNER"}}
{"actor":{"display_login":"oaboluwarin"}}