{"action":"created","comment":{"url":"https://api.github.com/repos/ryanchew3/fqe/pulls/comments/135156474","pull_request_review_id":58537651,"id":135156474,"diff_hunk":"@@ -0,0 +1,133 @@\n+//testController.js\n+\n+const Joi           =   require('Joi');\n+const Boom          =   require('Boom');\n+const Mongoose      =   require('Mongoose');\n+\n+const Component     =   require('../../models/Component').Component;\n+const TestData      =   require('../../models/TestData').TestData;\n+\n+\n+exports.showAPI = {\n+    handler: function(request, reply) {\n+        reply({\n+            'message': 'Hello API!'\n+        })\n+    }\n+};\n+\n+exports.getTestData = {\n+    handler: function(request, reply) {\n+        TestData.find({}, function(err, testData) {\n+            if (!err) {\n+                reply(testData);\n+            }\n+            else {\n+                reply(Boom.badImplementation(err));\n+            }\n+        });\n+    }\n+}\n+\n+\n+exports.getOneTestData =  {\n+    handler: function(request, reply) {\n+        TestData.findOne({\n+            'testId': request.params.testId\n+        }, function(err, user) {\n+            if (!err) {\n+                reply(user);\n+            } else {\n+                reply(Boom.badImplementation(err)); // 500 error\n+            }\n+        });\n+    }\n+}\n+\n+\n+exports.create = {\n+    validate: {\n+        payload: {\n+            testId: Joi.string().required(),\n+            randomString: Joi.string().required()\n+        }\n+    },\n+    handler: function(request, reply) {\n+        const testData = new TestData(request.payload);\n+        testData._id = Mongoose.Types.ObjectId();\n+        TestData.findOne({\n+          'testId': request.params.testId\n+        }, function(err1, testId) {\n+          if(!err1) {\n+            reply('This DataID has been taken');\n+          }\n+          else {\n+            testData.save(function(err, testData) {\n+                console.log(err);\n+                if (!err) {\n+                    reply(testData).created('/api/testData/' + testData._id); // HTTP 201\n+                }\n+                else {\n+                    if (11000 === err.code || 11001 === err.code) {\n+                        reply(Boom.forbidden(\"please provide another test id, it already exist\"));\n+                    }\n+                    else reply(Boom.forbidden(getErrorMessageFrom(err))); // HTTP 403\n+                }\n+            });\n+          }\n+        })\n+    }\n+}\n+\n+exports.update = {\n+    validate: {\n+        payload: {\n+            testId: Joi.string().required(),\n+            randomString: Joi.string().required()\n+        }\n+    },\n+    handler: function(request, reply) {\n+        TestData.findOne({","path":"routes/controllers/testController.js","position":90,"original_position":90,"commit_id":"6fed76e5883fc42d1661573f207bd4c06dd703e0","original_commit_id":"6fed76e5883fc42d1661573f207bd4c06dd703e0","user":{"login":"hugomd","id":1646536,"avatar_url":"https://avatars2.githubusercontent.com/u/1646536?v=4","gravatar_id":"","url":"https://api.github.com/users/hugomd","html_url":"https://github.com/hugomd","followers_url":"https://api.github.com/users/hugomd/followers","following_url":"https://api.github.com/users/hugomd/following{/other_user}","gists_url":"https://api.github.com/users/hugomd/gists{/gist_id}","starred_url":"https://api.github.com/users/hugomd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hugomd/subscriptions","organizations_url":"https://api.github.com/users/hugomd/orgs","repos_url":"https://api.github.com/users/hugomd/repos","events_url":"https://api.github.com/users/hugomd/events{/privacy}","received_events_url":"https://api.github.com/users/hugomd/received_events","type":"User","site_admin":false},"body":"Check out [Mongoose findOneAndUpdate](http://mongoosejs.com/docs/api.html#query_Query-findOneAndUpdate)","created_at":"2017-08-24T23:38:38Z","updated_at":"2017-08-24T23:39:57Z","html_url":"https://github.com/ryanchew3/fqe/pull/2#discussion_r135156474","pull_request_url":"https://api.github.com/repos/ryanchew3/fqe/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/ryanchew3/fqe/pulls/comments/135156474"},"html":{"href":"https://github.com/ryanchew3/fqe/pull/2#discussion_r135156474"},"pull_request":{"href":"https://api.github.com/repos/ryanchew3/fqe/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/ryanchew3/fqe/pulls/2","id":137570746,"html_url":"https://github.com/ryanchew3/fqe/pull/2","diff_url":"https://github.com/ryanchew3/fqe/pull/2.diff","patch_url":"https://github.com/ryanchew3/fqe/pull/2.patch","issue_url":"https://api.github.com/repos/ryanchew3/fqe/issues/2","number":2,"state":"open","locked":false,"title":"latest to earliest","user":{"login":"ryanchew3","id":12423566,"avatar_url":"https://avatars3.githubusercontent.com/u/12423566?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanchew3","html_url":"https://github.com/ryanchew3","followers_url":"https://api.github.com/users/ryanchew3/followers","following_url":"https://api.github.com/users/ryanchew3/following{/other_user}","gists_url":"https://api.github.com/users/ryanchew3/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanchew3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanchew3/subscriptions","organizations_url":"https://api.github.com/users/ryanchew3/orgs","repos_url":"https://api.github.com/users/ryanchew3/repos","events_url":"https://api.github.com/users/ryanchew3/events{/privacy}","received_events_url":"https://api.github.com/users/ryanchew3/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-08-24T23:09:28Z","updated_at":"2017-08-24T23:39:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"75ea990e9202d683d14c67ef8f70d74b3b584192","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/ryanchew3/fqe/pulls/2/commits","review_comments_url":"https://api.github.com/repos/ryanchew3/fqe/pulls/2/comments","review_comment_url":"https://api.github.com/repos/ryanchew3/fqe/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ryanchew3/fqe/issues/2/comments","statuses_url":"https://api.github.com/repos/ryanchew3/fqe/statuses/6fed76e5883fc42d1661573f207bd4c06dd703e0","head":{"label":"ryanchew3:feature-controller","ref":"feature-controller","sha":"6fed76e5883fc42d1661573f207bd4c06dd703e0","user":{"login":"ryanchew3","id":12423566,"avatar_url":"https://avatars3.githubusercontent.com/u/12423566?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanchew3","html_url":"https://github.com/ryanchew3","followers_url":"https://api.github.com/users/ryanchew3/followers","following_url":"https://api.github.com/users/ryanchew3/following{/other_user}","gists_url":"https://api.github.com/users/ryanchew3/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanchew3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanchew3/subscriptions","organizations_url":"https://api.github.com/users/ryanchew3/orgs","repos_url":"https://api.github.com/users/ryanchew3/repos","events_url":"https://api.github.com/users/ryanchew3/events{/privacy}","received_events_url":"https://api.github.com/users/ryanchew3/received_events","type":"User","site_admin":false},"repo":{"id":100798303,"name":"fqe","full_name":"ryanchew3/fqe","owner":{"login":"ryanchew3","id":12423566,"avatar_url":"https://avatars3.githubusercontent.com/u/12423566?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanchew3","html_url":"https://github.com/ryanchew3","followers_url":"https://api.github.com/users/ryanchew3/followers","following_url":"https://api.github.com/users/ryanchew3/following{/other_user}","gists_url":"https://api.github.com/users/ryanchew3/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanchew3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanchew3/subscriptions","organizations_url":"https://api.github.com/users/ryanchew3/orgs","repos_url":"https://api.github.com/users/ryanchew3/repos","events_url":"https://api.github.com/users/ryanchew3/events{/privacy}","received_events_url":"https://api.github.com/users/ryanchew3/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ryanchew3/fqe","description":null,"fork":false,"url":"https://api.github.com/repos/ryanchew3/fqe","forks_url":"https://api.github.com/repos/ryanchew3/fqe/forks","keys_url":"https://api.github.com/repos/ryanchew3/fqe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ryanchew3/fqe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ryanchew3/fqe/teams","hooks_url":"https://api.github.com/repos/ryanchew3/fqe/hooks","issue_events_url":"https://api.github.com/repos/ryanchew3/fqe/issues/events{/number}","events_url":"https://api.github.com/repos/ryanchew3/fqe/events","assignees_url":"https://api.github.com/repos/ryanchew3/fqe/assignees{/user}","branches_url":"https://api.github.com/repos/ryanchew3/fqe/branches{/branch}","tags_url":"https://api.github.com/repos/ryanchew3/fqe/tags","blobs_url":"https://api.github.com/repos/ryanchew3/fqe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ryanchew3/fqe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ryanchew3/fqe/git/refs{/sha}","trees_url":"https://api.github.com/repos/ryanchew3/fqe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ryanchew3/fqe/statuses/{sha}","languages_url":"https://api.github.com/repos/ryanchew3/fqe/languages","stargazers_url":"https://api.github.com/repos/ryanchew3/fqe/stargazers","contributors_url":"https://api.github.com/repos/ryanchew3/fqe/contributors","subscribers_url":"https://api.github.com/repos/ryanchew3/fqe/subscribers","subscription_url":"https://api.github.com/repos/ryanchew3/fqe/subscription","commits_url":"https://api.github.com/repos/ryanchew3/fqe/commits{/sha}","git_commits_url":"https://api.github.com/repos/ryanchew3/fqe/git/commits{/sha}","comments_url":"https://api.github.com/repos/ryanchew3/fqe/comments{/number}","issue_comment_url":"https://api.github.com/repos/ryanchew3/fqe/issues/comments{/number}","contents_url":"https://api.github.com/repos/ryanchew3/fqe/contents/{+path}","compare_url":"https://api.github.com/repos/ryanchew3/fqe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ryanchew3/fqe/merges","archive_url":"https://api.github.com/repos/ryanchew3/fqe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ryanchew3/fqe/downloads","issues_url":"https://api.github.com/repos/ryanchew3/fqe/issues{/number}","pulls_url":"https://api.github.com/repos/ryanchew3/fqe/pulls{/number}","milestones_url":"https://api.github.com/repos/ryanchew3/fqe/milestones{/number}","notifications_url":"https://api.github.com/repos/ryanchew3/fqe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ryanchew3/fqe/labels{/name}","releases_url":"https://api.github.com/repos/ryanchew3/fqe/releases{/id}","deployments_url":"https://api.github.com/repos/ryanchew3/fqe/deployments","created_at":"2017-08-19T14:06:38Z","updated_at":"2017-08-22T11:30:25Z","pushed_at":"2017-08-24T23:09:28Z","git_url":"git://github.com/ryanchew3/fqe.git","ssh_url":"git@github.com:ryanchew3/fqe.git","clone_url":"https://github.com/ryanchew3/fqe.git","svn_url":"https://github.com/ryanchew3/fqe","homepage":null,"size":36,"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,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ryanchew3:initial-commit","ref":"initial-commit","sha":"837fafeb07577bbb070ff01587339deebfab622a","user":{"login":"ryanchew3","id":12423566,"avatar_url":"https://avatars3.githubusercontent.com/u/12423566?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanchew3","html_url":"https://github.com/ryanchew3","followers_url":"https://api.github.com/users/ryanchew3/followers","following_url":"https://api.github.com/users/ryanchew3/following{/other_user}","gists_url":"https://api.github.com/users/ryanchew3/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanchew3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanchew3/subscriptions","organizations_url":"https://api.github.com/users/ryanchew3/orgs","repos_url":"https://api.github.com/users/ryanchew3/repos","events_url":"https://api.github.com/users/ryanchew3/events{/privacy}","received_events_url":"https://api.github.com/users/ryanchew3/received_events","type":"User","site_admin":false},"repo":{"id":100798303,"name":"fqe","full_name":"ryanchew3/fqe","owner":{"login":"ryanchew3","id":12423566,"avatar_url":"https://avatars3.githubusercontent.com/u/12423566?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanchew3","html_url":"https://github.com/ryanchew3","followers_url":"https://api.github.com/users/ryanchew3/followers","following_url":"https://api.github.com/users/ryanchew3/following{/other_user}","gists_url":"https://api.github.com/users/ryanchew3/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanchew3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanchew3/subscriptions","organizations_url":"https://api.github.com/users/ryanchew3/orgs","repos_url":"https://api.github.com/users/ryanchew3/repos","events_url":"https://api.github.com/users/ryanchew3/events{/privacy}","received_events_url":"https://api.github.com/users/ryanchew3/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ryanchew3/fqe","description":null,"fork":false,"url":"https://api.github.com/repos/ryanchew3/fqe","forks_url":"https://api.github.com/repos/ryanchew3/fqe/forks","keys_url":"https://api.github.com/repos/ryanchew3/fqe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ryanchew3/fqe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ryanchew3/fqe/teams","hooks_url":"https://api.github.com/repos/ryanchew3/fqe/hooks","issue_events_url":"https://api.github.com/repos/ryanchew3/fqe/issues/events{/number}","events_url":"https://api.github.com/repos/ryanchew3/fqe/events","assignees_url":"https://api.github.com/repos/ryanchew3/fqe/assignees{/user}","branches_url":"https://api.github.com/repos/ryanchew3/fqe/branches{/branch}","tags_url":"https://api.github.com/repos/ryanchew3/fqe/tags","blobs_url":"https://api.github.com/repos/ryanchew3/fqe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ryanchew3/fqe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ryanchew3/fqe/git/refs{/sha}","trees_url":"https://api.github.com/repos/ryanchew3/fqe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ryanchew3/fqe/statuses/{sha}","languages_url":"https://api.github.com/repos/ryanchew3/fqe/languages","stargazers_url":"https://api.github.com/repos/ryanchew3/fqe/stargazers","contributors_url":"https://api.github.com/repos/ryanchew3/fqe/contributors","subscribers_url":"https://api.github.com/repos/ryanchew3/fqe/subscribers","subscription_url":"https://api.github.com/repos/ryanchew3/fqe/subscription","commits_url":"https://api.github.com/repos/ryanchew3/fqe/commits{/sha}","git_commits_url":"https://api.github.com/repos/ryanchew3/fqe/git/commits{/sha}","comments_url":"https://api.github.com/repos/ryanchew3/fqe/comments{/number}","issue_comment_url":"https://api.github.com/repos/ryanchew3/fqe/issues/comments{/number}","contents_url":"https://api.github.com/repos/ryanchew3/fqe/contents/{+path}","compare_url":"https://api.github.com/repos/ryanchew3/fqe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ryanchew3/fqe/merges","archive_url":"https://api.github.com/repos/ryanchew3/fqe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ryanchew3/fqe/downloads","issues_url":"https://api.github.com/repos/ryanchew3/fqe/issues{/number}","pulls_url":"https://api.github.com/repos/ryanchew3/fqe/pulls{/number}","milestones_url":"https://api.github.com/repos/ryanchew3/fqe/milestones{/number}","notifications_url":"https://api.github.com/repos/ryanchew3/fqe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ryanchew3/fqe/labels{/name}","releases_url":"https://api.github.com/repos/ryanchew3/fqe/releases{/id}","deployments_url":"https://api.github.com/repos/ryanchew3/fqe/deployments","created_at":"2017-08-19T14:06:38Z","updated_at":"2017-08-22T11:30:25Z","pushed_at":"2017-08-24T23:09:28Z","git_url":"git://github.com/ryanchew3/fqe.git","ssh_url":"git@github.com:ryanchew3/fqe.git","clone_url":"https://github.com/ryanchew3/fqe.git","svn_url":"https://github.com/ryanchew3/fqe","homepage":null,"size":36,"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,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ryanchew3/fqe/pulls/2"},"html":{"href":"https://github.com/ryanchew3/fqe/pull/2"},"issue":{"href":"https://api.github.com/repos/ryanchew3/fqe/issues/2"},"comments":{"href":"https://api.github.com/repos/ryanchew3/fqe/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/ryanchew3/fqe/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/ryanchew3/fqe/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ryanchew3/fqe/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/ryanchew3/fqe/statuses/6fed76e5883fc42d1661573f207bd4c06dd703e0"}}}}
{"actor":{"display_login":"hugomd"}}