{"action":"created","comment":{"url":"https://api.github.com/repos/henperi/fincare-bend/pulls/comments/294039332","pull_request_review_id":250184037,"id":294039332,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI5NDAzOTMzMg==","diff_hunk":"@@ -0,0 +1,58 @@\n+import moment from 'moment';\n+import response from '../../helpers/responses';\n+import validateReqKeys from './validateReqKeys';\n+import requireFields from './requireFields';\n+\n+const expenseMethods = {\n+  validateCreate: (req, res, next) => {\n+    requireFields(req, ['expenseTitle', 'amount', 'description', 'category']);\n+\n+    validateReqKeys(req, Object.keys(req.body));\n+\n+    const errors = req.validationErrors();\n+    if (errors) {\n+      return response.badRequest(res, { errors });\n+    }\n+\n+    return next();\n+  },\n+\n+  validateFetchAll: (req, res, next) => {\n+    const { startDate, endDate } = req.query;\n+\n+    if (startDate && endDate) {\n+      // Verify the dates\n+      const expectedFormats = ['YYYY-MM-DD', 'MM-DD-YYYY'];\n+\n+      const validateStartDate = moment(startDate, expectedFormats, true).isValid();\n+      const validateEndDate = moment(endDate, expectedFormats, true).isValid();\n+\n+      if (!validateStartDate) {\n+        const message = `The start date supplied is invalid. it should be formated as ${\n+          expectedFormats[0]\n+        } or ${expectedFormats[1]}`;\n+        return response.badRequest(res, { issue: 'queryParam', message });\n+      }\n+\n+      if (!validateEndDate) {","path":"server/middlewares/validation/expenseMethods.js","position":37,"original_position":37,"commit_id":"79fa9353b363fbd49c9e0d0a5b49af1d0a35020c","original_commit_id":"79fa9353b363fbd49c9e0d0a5b49af1d0a35020c","user":{"login":"codeclimate[bot]","id":36754821,"node_id":"MDM6Qm90MzY3NTQ4MjE=","avatar_url":"https://avatars0.githubusercontent.com/in/9403?v=4","gravatar_id":"","url":"https://api.github.com/users/codeclimate%5Bbot%5D","html_url":"https://github.com/apps/codeclimate","followers_url":"https://api.github.com/users/codeclimate%5Bbot%5D/followers","following_url":"https://api.github.com/users/codeclimate%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/codeclimate%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/codeclimate%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeclimate%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/codeclimate%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/codeclimate%5Bbot%5D/repos","events_url":"https://api.github.com/users/codeclimate%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/codeclimate%5Bbot%5D/received_events","type":"Bot","site_admin":false},"body":"Similar blocks of code found in 2 locations. Consider refactoring.","created_at":"2019-06-15T08:16:37Z","updated_at":"2019-06-15T08:16:37Z","html_url":"https://github.com/henperi/fincare-bend/pull/39#discussion_r294039332","pull_request_url":"https://api.github.com/repos/henperi/fincare-bend/pulls/39","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/henperi/fincare-bend/pulls/comments/294039332"},"html":{"href":"https://github.com/henperi/fincare-bend/pull/39#discussion_r294039332"},"pull_request":{"href":"https://api.github.com/repos/henperi/fincare-bend/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/henperi/fincare-bend/pulls/39","id":287995884,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjg3OTk1ODg0","html_url":"https://github.com/henperi/fincare-bend/pull/39","diff_url":"https://github.com/henperi/fincare-bend/pull/39.diff","patch_url":"https://github.com/henperi/fincare-bend/pull/39.patch","issue_url":"https://api.github.com/repos/henperi/fincare-bend/issues/39","number":39,"state":"open","locked":false,"title":"feat(expenses): create and fetch expenses","user":{"login":"henperi","id":36136977,"node_id":"MDQ6VXNlcjM2MTM2OTc3","avatar_url":"https://avatars0.githubusercontent.com/u/36136977?v=4","gravatar_id":"","url":"https://api.github.com/users/henperi","html_url":"https://github.com/henperi","followers_url":"https://api.github.com/users/henperi/followers","following_url":"https://api.github.com/users/henperi/following{/other_user}","gists_url":"https://api.github.com/users/henperi/gists{/gist_id}","starred_url":"https://api.github.com/users/henperi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henperi/subscriptions","organizations_url":"https://api.github.com/users/henperi/orgs","repos_url":"https://api.github.com/users/henperi/repos","events_url":"https://api.github.com/users/henperi/events{/privacy}","received_events_url":"https://api.github.com/users/henperi/received_events","type":"User","site_admin":false},"body":"[Finishes #166408338, #166408522]","created_at":"2019-06-13T16:03:10Z","updated_at":"2019-06-15T08:16:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"06c49f5603281f30080f5c7f21b3d1e14d2814ce","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/henperi/fincare-bend/pulls/39/commits","review_comments_url":"https://api.github.com/repos/henperi/fincare-bend/pulls/39/comments","review_comment_url":"https://api.github.com/repos/henperi/fincare-bend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/henperi/fincare-bend/issues/39/comments","statuses_url":"https://api.github.com/repos/henperi/fincare-bend/statuses/79fa9353b363fbd49c9e0d0a5b49af1d0a35020c","head":{"label":"henperi:ft-record-and-fetch-expenses-166408338-166408522","ref":"ft-record-and-fetch-expenses-166408338-166408522","sha":"79fa9353b363fbd49c9e0d0a5b49af1d0a35020c","user":{"login":"henperi","id":36136977,"node_id":"MDQ6VXNlcjM2MTM2OTc3","avatar_url":"https://avatars0.githubusercontent.com/u/36136977?v=4","gravatar_id":"","url":"https://api.github.com/users/henperi","html_url":"https://github.com/henperi","followers_url":"https://api.github.com/users/henperi/followers","following_url":"https://api.github.com/users/henperi/following{/other_user}","gists_url":"https://api.github.com/users/henperi/gists{/gist_id}","starred_url":"https://api.github.com/users/henperi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henperi/subscriptions","organizations_url":"https://api.github.com/users/henperi/orgs","repos_url":"https://api.github.com/users/henperi/repos","events_url":"https://api.github.com/users/henperi/events{/privacy}","received_events_url":"https://api.github.com/users/henperi/received_events","type":"User","site_admin":false},"repo":{"id":186939654,"node_id":"MDEwOlJlcG9zaXRvcnkxODY5Mzk2NTQ=","name":"fincare-bend","full_name":"henperi/fincare-bend","private":false,"owner":{"login":"henperi","id":36136977,"node_id":"MDQ6VXNlcjM2MTM2OTc3","avatar_url":"https://avatars0.githubusercontent.com/u/36136977?v=4","gravatar_id":"","url":"https://api.github.com/users/henperi","html_url":"https://github.com/henperi","followers_url":"https://api.github.com/users/henperi/followers","following_url":"https://api.github.com/users/henperi/following{/other_user}","gists_url":"https://api.github.com/users/henperi/gists{/gist_id}","starred_url":"https://api.github.com/users/henperi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henperi/subscriptions","organizations_url":"https://api.github.com/users/henperi/orgs","repos_url":"https://api.github.com/users/henperi/repos","events_url":"https://api.github.com/users/henperi/events{/privacy}","received_events_url":"https://api.github.com/users/henperi/received_events","type":"User","site_admin":false},"html_url":"https://github.com/henperi/fincare-bend","description":null,"fork":false,"url":"https://api.github.com/repos/henperi/fincare-bend","forks_url":"https://api.github.com/repos/henperi/fincare-bend/forks","keys_url":"https://api.github.com/repos/henperi/fincare-bend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/henperi/fincare-bend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/henperi/fincare-bend/teams","hooks_url":"https://api.github.com/repos/henperi/fincare-bend/hooks","issue_events_url":"https://api.github.com/repos/henperi/fincare-bend/issues/events{/number}","events_url":"https://api.github.com/repos/henperi/fincare-bend/events","assignees_url":"https://api.github.com/repos/henperi/fincare-bend/assignees{/user}","branches_url":"https://api.github.com/repos/henperi/fincare-bend/branches{/branch}","tags_url":"https://api.github.com/repos/henperi/fincare-bend/tags","blobs_url":"https://api.github.com/repos/henperi/fincare-bend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/henperi/fincare-bend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/henperi/fincare-bend/git/refs{/sha}","trees_url":"https://api.github.com/repos/henperi/fincare-bend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/henperi/fincare-bend/statuses/{sha}","languages_url":"https://api.github.com/repos/henperi/fincare-bend/languages","stargazers_url":"https://api.github.com/repos/henperi/fincare-bend/stargazers","contributors_url":"https://api.github.com/repos/henperi/fincare-bend/contributors","subscribers_url":"https://api.github.com/repos/henperi/fincare-bend/subscribers","subscription_url":"https://api.github.com/repos/henperi/fincare-bend/subscription","commits_url":"https://api.github.com/repos/henperi/fincare-bend/commits{/sha}","git_commits_url":"https://api.github.com/repos/henperi/fincare-bend/git/commits{/sha}","comments_url":"https://api.github.com/repos/henperi/fincare-bend/comments{/number}","issue_comment_url":"https://api.github.com/repos/henperi/fincare-bend/issues/comments{/number}","contents_url":"https://api.github.com/repos/henperi/fincare-bend/contents/{+path}","compare_url":"https://api.github.com/repos/henperi/fincare-bend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/henperi/fincare-bend/merges","archive_url":"https://api.github.com/repos/henperi/fincare-bend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/henperi/fincare-bend/downloads","issues_url":"https://api.github.com/repos/henperi/fincare-bend/issues{/number}","pulls_url":"https://api.github.com/repos/henperi/fincare-bend/pulls{/number}","milestones_url":"https://api.github.com/repos/henperi/fincare-bend/milestones{/number}","notifications_url":"https://api.github.com/repos/henperi/fincare-bend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/henperi/fincare-bend/labels{/name}","releases_url":"https://api.github.com/repos/henperi/fincare-bend/releases{/id}","deployments_url":"https://api.github.com/repos/henperi/fincare-bend/deployments","created_at":"2019-05-16T02:53:42Z","updated_at":"2019-06-06T19:39:25Z","pushed_at":"2019-06-15T08:14:32Z","git_url":"git://github.com/henperi/fincare-bend.git","ssh_url":"git@github.com:henperi/fincare-bend.git","clone_url":"https://github.com/henperi/fincare-bend.git","svn_url":"https://github.com/henperi/fincare-bend","homepage":null,"size":457,"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,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"henperi:develop","ref":"develop","sha":"f5fdf81638ded7dad9f84ad92fe83a9c77a6f07c","user":{"login":"henperi","id":36136977,"node_id":"MDQ6VXNlcjM2MTM2OTc3","avatar_url":"https://avatars0.githubusercontent.com/u/36136977?v=4","gravatar_id":"","url":"https://api.github.com/users/henperi","html_url":"https://github.com/henperi","followers_url":"https://api.github.com/users/henperi/followers","following_url":"https://api.github.com/users/henperi/following{/other_user}","gists_url":"https://api.github.com/users/henperi/gists{/gist_id}","starred_url":"https://api.github.com/users/henperi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henperi/subscriptions","organizations_url":"https://api.github.com/users/henperi/orgs","repos_url":"https://api.github.com/users/henperi/repos","events_url":"https://api.github.com/users/henperi/events{/privacy}","received_events_url":"https://api.github.com/users/henperi/received_events","type":"User","site_admin":false},"repo":{"id":186939654,"node_id":"MDEwOlJlcG9zaXRvcnkxODY5Mzk2NTQ=","name":"fincare-bend","full_name":"henperi/fincare-bend","private":false,"owner":{"login":"henperi","id":36136977,"node_id":"MDQ6VXNlcjM2MTM2OTc3","avatar_url":"https://avatars0.githubusercontent.com/u/36136977?v=4","gravatar_id":"","url":"https://api.github.com/users/henperi","html_url":"https://github.com/henperi","followers_url":"https://api.github.com/users/henperi/followers","following_url":"https://api.github.com/users/henperi/following{/other_user}","gists_url":"https://api.github.com/users/henperi/gists{/gist_id}","starred_url":"https://api.github.com/users/henperi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henperi/subscriptions","organizations_url":"https://api.github.com/users/henperi/orgs","repos_url":"https://api.github.com/users/henperi/repos","events_url":"https://api.github.com/users/henperi/events{/privacy}","received_events_url":"https://api.github.com/users/henperi/received_events","type":"User","site_admin":false},"html_url":"https://github.com/henperi/fincare-bend","description":null,"fork":false,"url":"https://api.github.com/repos/henperi/fincare-bend","forks_url":"https://api.github.com/repos/henperi/fincare-bend/forks","keys_url":"https://api.github.com/repos/henperi/fincare-bend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/henperi/fincare-bend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/henperi/fincare-bend/teams","hooks_url":"https://api.github.com/repos/henperi/fincare-bend/hooks","issue_events_url":"https://api.github.com/repos/henperi/fincare-bend/issues/events{/number}","events_url":"https://api.github.com/repos/henperi/fincare-bend/events","assignees_url":"https://api.github.com/repos/henperi/fincare-bend/assignees{/user}","branches_url":"https://api.github.com/repos/henperi/fincare-bend/branches{/branch}","tags_url":"https://api.github.com/repos/henperi/fincare-bend/tags","blobs_url":"https://api.github.com/repos/henperi/fincare-bend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/henperi/fincare-bend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/henperi/fincare-bend/git/refs{/sha}","trees_url":"https://api.github.com/repos/henperi/fincare-bend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/henperi/fincare-bend/statuses/{sha}","languages_url":"https://api.github.com/repos/henperi/fincare-bend/languages","stargazers_url":"https://api.github.com/repos/henperi/fincare-bend/stargazers","contributors_url":"https://api.github.com/repos/henperi/fincare-bend/contributors","subscribers_url":"https://api.github.com/repos/henperi/fincare-bend/subscribers","subscription_url":"https://api.github.com/repos/henperi/fincare-bend/subscription","commits_url":"https://api.github.com/repos/henperi/fincare-bend/commits{/sha}","git_commits_url":"https://api.github.com/repos/henperi/fincare-bend/git/commits{/sha}","comments_url":"https://api.github.com/repos/henperi/fincare-bend/comments{/number}","issue_comment_url":"https://api.github.com/repos/henperi/fincare-bend/issues/comments{/number}","contents_url":"https://api.github.com/repos/henperi/fincare-bend/contents/{+path}","compare_url":"https://api.github.com/repos/henperi/fincare-bend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/henperi/fincare-bend/merges","archive_url":"https://api.github.com/repos/henperi/fincare-bend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/henperi/fincare-bend/downloads","issues_url":"https://api.github.com/repos/henperi/fincare-bend/issues{/number}","pulls_url":"https://api.github.com/repos/henperi/fincare-bend/pulls{/number}","milestones_url":"https://api.github.com/repos/henperi/fincare-bend/milestones{/number}","notifications_url":"https://api.github.com/repos/henperi/fincare-bend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/henperi/fincare-bend/labels{/name}","releases_url":"https://api.github.com/repos/henperi/fincare-bend/releases{/id}","deployments_url":"https://api.github.com/repos/henperi/fincare-bend/deployments","created_at":"2019-05-16T02:53:42Z","updated_at":"2019-06-06T19:39:25Z","pushed_at":"2019-06-15T08:14:32Z","git_url":"git://github.com/henperi/fincare-bend.git","ssh_url":"git@github.com:henperi/fincare-bend.git","clone_url":"https://github.com/henperi/fincare-bend.git","svn_url":"https://github.com/henperi/fincare-bend","homepage":null,"size":457,"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,"disabled":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/henperi/fincare-bend/pulls/39"},"html":{"href":"https://github.com/henperi/fincare-bend/pull/39"},"issue":{"href":"https://api.github.com/repos/henperi/fincare-bend/issues/39"},"comments":{"href":"https://api.github.com/repos/henperi/fincare-bend/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/henperi/fincare-bend/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/henperi/fincare-bend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/henperi/fincare-bend/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/henperi/fincare-bend/statuses/79fa9353b363fbd49c9e0d0a5b49af1d0a35020c"}},"author_association":"OWNER"}}
{"actor":{"display_login":"codeclimate"}}