{"action":"created","comment":{"url":"https://api.github.com/repos/Metali/api_service_web/pulls/comments/25997237","id":25997237,"diff_hunk":"@@ -0,0 +1,191 @@\n+var express = require('express');\r\n+var Reviews = require('../database/Reviews');\r\n+var router = express.Router();\r\n+\r\n+// get all - HTML & JSON\r\n+router.get('/reviews', function (req, res) {\r\n+\tif (req.accepts('text/html')){\r\n+\t\tReviews.find({}, function (err, Reviews) {\r\n+\t\t\tif (err) {\r\n+\t\t\t\tres.status(500).send({'error': err});\r\n+\t\t\t} else {\r\n+\t\t\t\tres.status(200).render('reviews', { reviews: Reviews});\t\r\n+\t\t\t}\r\n+\t\t});\r\n+\t} else if(req.accepts('application/json') || req.headers.accept == \"application/json\") {\r\n+\t\tReviews.find({}, function (err, Reviews) {\r\n+\t\t\tif (err) {\r\n+\t\t\t\tres.status(500).send({'error': err});\r\n+\t\t\t} else {\r\n+\t\t\t\tres.status(200).send(Reviews);\r\n+\t\t\t}\r\n+\t\t});\r\n+\t} else {\r\n+\t\tres.status(400).send({'error': \"specify an header accept\"});\r\n+\t}\r\n+\r\n+});\r\n+\r\n+// add one - HTML template\r\n+router.get('/review/add', function(req, res, next) {\r\n+\tif (req.accepts('text/html')){\r\n+\t\tres.status(200).render('add');\t\r\n+\t} else if(req.accepts('application/json') || req.headers.accept == \"application/json\") {\r\n+\t\tres.status(400).send({'error': \"Route need to be call from a browser\"});\t\r\n+\t} else {\r\n+\t\tres.status(400).send({'error': \"specify an header accept\"});\r\n+\t}\r\n+});\r\n+\r\n+// add one - API call\r\n+router.post('/reviews', function(req, res) {\r\n+\t\r\n+\tif(!req.body.name || !req.body.placeType || !req.body.stars) {\r\n+\t\tres.status(400).send({'error': 'Fields empty'});\r\n+\t} else {\r\n+\t\tvar review = new Reviews({\r\n+\t\t\tname: req.body.name,\r\n+\t\t\tplaceType: req.body.placeType,\r\n+\t\t\tstars: req.body.stars\r\n+\t\t})\r\n+\t\tReviews.create(review, function (err, Reviews) {\r\n+\t\t\tif (err) {\r\n+\t\t\t\tres.status(500).send({'error': err});\r\n+\t\t\t} else {\t\r\n+\t\t\t\tres.status(201).send(Reviews);\r\n+\t\t\t}\r\n+\t\t});\r\n+\t}\r\n+});\r\n+\r\n+// delete all\r\n+router.delete('/review/delete', function(req, res, next) {\r\n+\tReviews.remove(function (err, Reviews) {\r\n+\t\tif (err) {\r\n+\t\t\tres.status(500).send({'error': err});\r\n+\t\t} else {\t\r\n+\t\t\tres.status(200).send(Reviews);\r\n+\t\t}\r\n+\t});\r\n+});\r\n+\r\n+// get one \r\n+router.get('/review/:id', function (req, res) {\r\n+\tif(!req.params.id) {\r\n+\t\tres.status(404).send(\"ID required\");\r\n+\t} else {\r\n+\t\tReviews.find({\"_id\": req.params.id}, function (err, Reviews) {\r\n+\t\t\tif (err) {\r\n+\t\t\t\tres.status(500).send({'error': err});\r\n+\t\t\t} else {\r\n+\t\t\t\tres.status(200).send(Reviews);\r\n+\t\t\t}\r\n+\t\t});\r\n+\t}\r\n+});\r\n+\r\n+// edit one - HTML template\r\n+router.get('/review/edit/:id', function(req, res, next) {\r\n+\tif (req.accepts('text/html')){\r\n+\t\tif(!req.params.id) {\r\n+\t\t\tres.status(404).send(\"ID required\");\r\n+\t\t} else {\r\n+\t\t\tReviews.find({\"_id\": req.params.id}, function (err, Reviews) {\r\n+\t\t\t\tif (err) {\r\n+\t\t\t\t\tres.status(404).send(\"incorrect ID\");\r\n+\t\t\t\t} else {\r\n+\t\t\t\t\tconsole.log(Reviews);\r\n+\t\t\t\t\tres.status(200).render('edit', { review: Reviews});\t\r\n+\r\n+\t\t\t\t}\r\n+\t\t\t});\r\n+\t\t}\r\n+\t} else if(req.accepts('application/json') || req.headers.accept == \"application/json\") {\r\n+\t\tres.status(400).send({'error': \"Route need to be call from a browser\"});\t\r\n+\t} else {\r\n+\t\tres.status(400).send({'error': \"specify an header accept\"});\r\n+\t}\r\n+});\r\n+\r\n+// edit one - API call\r\n+router.put('/review/edit/:id', function(req, res, next) {\r\n+\tif(!req.params.id) {\r\n+\t\tres.status(404).send(\"ID required\");\r\n+\t} else {\r\n+\t\tvar review = {\r\n+\t\t\tname: req.body.name,\r\n+\t\t\tplaceType: req.body.placeType,\r\n+\t\t\tstars: req.body.stars\r\n+\t\t}\r\n+\t\tReviews.findByIdAndUpdate(req.params.id,review, function (err, Reviews) {\r","path":"routes/reviews.js","position":120,"original_position":120,"commit_id":"410824fab8b6718e1146acc3e7f0b924035666b3","original_commit_id":"410824fab8b6718e1146acc3e7f0b924035666b3","user":{"login":"jomaora","id":7602475,"avatar_url":"https://avatars.githubusercontent.com/u/7602475?v=3","gravatar_id":"","url":"https://api.github.com/users/jomaora","html_url":"https://github.com/jomaora","followers_url":"https://api.github.com/users/jomaora/followers","following_url":"https://api.github.com/users/jomaora/following{/other_user}","gists_url":"https://api.github.com/users/jomaora/gists{/gist_id}","starred_url":"https://api.github.com/users/jomaora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jomaora/subscriptions","organizations_url":"https://api.github.com/users/jomaora/orgs","repos_url":"https://api.github.com/users/jomaora/repos","events_url":"https://api.github.com/users/jomaora/events{/privacy}","received_events_url":"https://api.github.com/users/jomaora/received_events","type":"User","site_admin":false},"body":"pas de majuscules !!\r\n```\r\nReviews.findByIdAndUpdate(req.params.id,review, function (err, reviews) {\r\n```","created_at":"2015-03-07T16:29:20Z","updated_at":"2015-03-07T16:29:20Z","html_url":"https://github.com/Metali/api_service_web/pull/2#discussion_r25997237","pull_request_url":"https://api.github.com/repos/Metali/api_service_web/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/Metali/api_service_web/pulls/comments/25997237"},"html":{"href":"https://github.com/Metali/api_service_web/pull/2#discussion_r25997237"},"pull_request":{"href":"https://api.github.com/repos/Metali/api_service_web/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/Metali/api_service_web/pulls/2","id":30485230,"html_url":"https://github.com/Metali/api_service_web/pull/2","diff_url":"https://github.com/Metali/api_service_web/pull/2.diff","patch_url":"https://github.com/Metali/api_service_web/pull/2.patch","issue_url":"https://api.github.com/repos/Metali/api_service_web/issues/2","number":2,"state":"open","locked":false,"title":"Code review","user":{"login":"jomaora","id":7602475,"avatar_url":"https://avatars.githubusercontent.com/u/7602475?v=3","gravatar_id":"","url":"https://api.github.com/users/jomaora","html_url":"https://github.com/jomaora","followers_url":"https://api.github.com/users/jomaora/followers","following_url":"https://api.github.com/users/jomaora/following{/other_user}","gists_url":"https://api.github.com/users/jomaora/gists{/gist_id}","starred_url":"https://api.github.com/users/jomaora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jomaora/subscriptions","organizations_url":"https://api.github.com/users/jomaora/orgs","repos_url":"https://api.github.com/users/jomaora/repos","events_url":"https://api.github.com/users/jomaora/events{/privacy}","received_events_url":"https://api.github.com/users/jomaora/received_events","type":"User","site_admin":false},"body":"Cette PR permettra de mettre les corrections et discuter sur ton code.","created_at":"2015-03-04T17:20:03Z","updated_at":"2015-03-07T16:29:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1ca6347db89e2318f71c020e38d2478aee68eb6a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Metali/api_service_web/pulls/2/commits","review_comments_url":"https://api.github.com/repos/Metali/api_service_web/pulls/2/comments","review_comment_url":"https://api.github.com/repos/Metali/api_service_web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Metali/api_service_web/issues/2/comments","statuses_url":"https://api.github.com/repos/Metali/api_service_web/statuses/410824fab8b6718e1146acc3e7f0b924035666b3","head":{"label":"Metali:TP2","ref":"TP2","sha":"410824fab8b6718e1146acc3e7f0b924035666b3","user":{"login":"Metali","id":7316692,"avatar_url":"https://avatars.githubusercontent.com/u/7316692?v=3","gravatar_id":"","url":"https://api.github.com/users/Metali","html_url":"https://github.com/Metali","followers_url":"https://api.github.com/users/Metali/followers","following_url":"https://api.github.com/users/Metali/following{/other_user}","gists_url":"https://api.github.com/users/Metali/gists{/gist_id}","starred_url":"https://api.github.com/users/Metali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metali/subscriptions","organizations_url":"https://api.github.com/users/Metali/orgs","repos_url":"https://api.github.com/users/Metali/repos","events_url":"https://api.github.com/users/Metali/events{/privacy}","received_events_url":"https://api.github.com/users/Metali/received_events","type":"User","site_admin":false},"repo":{"id":29961661,"name":"api_service_web","full_name":"Metali/api_service_web","owner":{"login":"Metali","id":7316692,"avatar_url":"https://avatars.githubusercontent.com/u/7316692?v=3","gravatar_id":"","url":"https://api.github.com/users/Metali","html_url":"https://github.com/Metali","followers_url":"https://api.github.com/users/Metali/followers","following_url":"https://api.github.com/users/Metali/following{/other_user}","gists_url":"https://api.github.com/users/Metali/gists{/gist_id}","starred_url":"https://api.github.com/users/Metali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metali/subscriptions","organizations_url":"https://api.github.com/users/Metali/orgs","repos_url":"https://api.github.com/users/Metali/repos","events_url":"https://api.github.com/users/Metali/events{/privacy}","received_events_url":"https://api.github.com/users/Metali/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Metali/api_service_web","description":"","fork":false,"url":"https://api.github.com/repos/Metali/api_service_web","forks_url":"https://api.github.com/repos/Metali/api_service_web/forks","keys_url":"https://api.github.com/repos/Metali/api_service_web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metali/api_service_web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metali/api_service_web/teams","hooks_url":"https://api.github.com/repos/Metali/api_service_web/hooks","issue_events_url":"https://api.github.com/repos/Metali/api_service_web/issues/events{/number}","events_url":"https://api.github.com/repos/Metali/api_service_web/events","assignees_url":"https://api.github.com/repos/Metali/api_service_web/assignees{/user}","branches_url":"https://api.github.com/repos/Metali/api_service_web/branches{/branch}","tags_url":"https://api.github.com/repos/Metali/api_service_web/tags","blobs_url":"https://api.github.com/repos/Metali/api_service_web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metali/api_service_web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metali/api_service_web/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metali/api_service_web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metali/api_service_web/statuses/{sha}","languages_url":"https://api.github.com/repos/Metali/api_service_web/languages","stargazers_url":"https://api.github.com/repos/Metali/api_service_web/stargazers","contributors_url":"https://api.github.com/repos/Metali/api_service_web/contributors","subscribers_url":"https://api.github.com/repos/Metali/api_service_web/subscribers","subscription_url":"https://api.github.com/repos/Metali/api_service_web/subscription","commits_url":"https://api.github.com/repos/Metali/api_service_web/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metali/api_service_web/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metali/api_service_web/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metali/api_service_web/issues/comments{/number}","contents_url":"https://api.github.com/repos/Metali/api_service_web/contents/{+path}","compare_url":"https://api.github.com/repos/Metali/api_service_web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metali/api_service_web/merges","archive_url":"https://api.github.com/repos/Metali/api_service_web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metali/api_service_web/downloads","issues_url":"https://api.github.com/repos/Metali/api_service_web/issues{/number}","pulls_url":"https://api.github.com/repos/Metali/api_service_web/pulls{/number}","milestones_url":"https://api.github.com/repos/Metali/api_service_web/milestones{/number}","notifications_url":"https://api.github.com/repos/Metali/api_service_web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metali/api_service_web/labels{/name}","releases_url":"https://api.github.com/repos/Metali/api_service_web/releases{/id}","created_at":"2015-01-28T10:11:50Z","updated_at":"2015-02-19T13:46:45Z","pushed_at":"2015-03-04T17:19:09Z","git_url":"git://github.com/Metali/api_service_web.git","ssh_url":"git@github.com:Metali/api_service_web.git","clone_url":"https://github.com/Metali/api_service_web.git","svn_url":"https://github.com/Metali/api_service_web","homepage":null,"size":236,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"TP2"}},"base":{"label":"Metali:code-review","ref":"code-review","sha":"cbfef656a0a250f8f3fd64562b54b70db3147fe5","user":{"login":"Metali","id":7316692,"avatar_url":"https://avatars.githubusercontent.com/u/7316692?v=3","gravatar_id":"","url":"https://api.github.com/users/Metali","html_url":"https://github.com/Metali","followers_url":"https://api.github.com/users/Metali/followers","following_url":"https://api.github.com/users/Metali/following{/other_user}","gists_url":"https://api.github.com/users/Metali/gists{/gist_id}","starred_url":"https://api.github.com/users/Metali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metali/subscriptions","organizations_url":"https://api.github.com/users/Metali/orgs","repos_url":"https://api.github.com/users/Metali/repos","events_url":"https://api.github.com/users/Metali/events{/privacy}","received_events_url":"https://api.github.com/users/Metali/received_events","type":"User","site_admin":false},"repo":{"id":29961661,"name":"api_service_web","full_name":"Metali/api_service_web","owner":{"login":"Metali","id":7316692,"avatar_url":"https://avatars.githubusercontent.com/u/7316692?v=3","gravatar_id":"","url":"https://api.github.com/users/Metali","html_url":"https://github.com/Metali","followers_url":"https://api.github.com/users/Metali/followers","following_url":"https://api.github.com/users/Metali/following{/other_user}","gists_url":"https://api.github.com/users/Metali/gists{/gist_id}","starred_url":"https://api.github.com/users/Metali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metali/subscriptions","organizations_url":"https://api.github.com/users/Metali/orgs","repos_url":"https://api.github.com/users/Metali/repos","events_url":"https://api.github.com/users/Metali/events{/privacy}","received_events_url":"https://api.github.com/users/Metali/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Metali/api_service_web","description":"","fork":false,"url":"https://api.github.com/repos/Metali/api_service_web","forks_url":"https://api.github.com/repos/Metali/api_service_web/forks","keys_url":"https://api.github.com/repos/Metali/api_service_web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metali/api_service_web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metali/api_service_web/teams","hooks_url":"https://api.github.com/repos/Metali/api_service_web/hooks","issue_events_url":"https://api.github.com/repos/Metali/api_service_web/issues/events{/number}","events_url":"https://api.github.com/repos/Metali/api_service_web/events","assignees_url":"https://api.github.com/repos/Metali/api_service_web/assignees{/user}","branches_url":"https://api.github.com/repos/Metali/api_service_web/branches{/branch}","tags_url":"https://api.github.com/repos/Metali/api_service_web/tags","blobs_url":"https://api.github.com/repos/Metali/api_service_web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metali/api_service_web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metali/api_service_web/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metali/api_service_web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metali/api_service_web/statuses/{sha}","languages_url":"https://api.github.com/repos/Metali/api_service_web/languages","stargazers_url":"https://api.github.com/repos/Metali/api_service_web/stargazers","contributors_url":"https://api.github.com/repos/Metali/api_service_web/contributors","subscribers_url":"https://api.github.com/repos/Metali/api_service_web/subscribers","subscription_url":"https://api.github.com/repos/Metali/api_service_web/subscription","commits_url":"https://api.github.com/repos/Metali/api_service_web/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metali/api_service_web/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metali/api_service_web/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metali/api_service_web/issues/comments{/number}","contents_url":"https://api.github.com/repos/Metali/api_service_web/contents/{+path}","compare_url":"https://api.github.com/repos/Metali/api_service_web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metali/api_service_web/merges","archive_url":"https://api.github.com/repos/Metali/api_service_web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metali/api_service_web/downloads","issues_url":"https://api.github.com/repos/Metali/api_service_web/issues{/number}","pulls_url":"https://api.github.com/repos/Metali/api_service_web/pulls{/number}","milestones_url":"https://api.github.com/repos/Metali/api_service_web/milestones{/number}","notifications_url":"https://api.github.com/repos/Metali/api_service_web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metali/api_service_web/labels{/name}","releases_url":"https://api.github.com/repos/Metali/api_service_web/releases{/id}","created_at":"2015-01-28T10:11:50Z","updated_at":"2015-02-19T13:46:45Z","pushed_at":"2015-03-04T17:19:09Z","git_url":"git://github.com/Metali/api_service_web.git","ssh_url":"git@github.com:Metali/api_service_web.git","clone_url":"https://github.com/Metali/api_service_web.git","svn_url":"https://github.com/Metali/api_service_web","homepage":null,"size":236,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"TP2"}},"_links":{"self":{"href":"https://api.github.com/repos/Metali/api_service_web/pulls/2"},"html":{"href":"https://github.com/Metali/api_service_web/pull/2"},"issue":{"href":"https://api.github.com/repos/Metali/api_service_web/issues/2"},"comments":{"href":"https://api.github.com/repos/Metali/api_service_web/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/Metali/api_service_web/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/Metali/api_service_web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Metali/api_service_web/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/Metali/api_service_web/statuses/410824fab8b6718e1146acc3e7f0b924035666b3"}}}}