{"action":"created","comment":{"url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/comments/27058070","id":27058070,"diff_hunk":"@@ -0,0 +1,287 @@\n+var express = require('express');\n+var Reviews = require('../database/reviews');\n+var accepts = require('accepts')\n+var router = express.Router();\n+\n+\n+// Route GET/add : Retourne le formulaire de création d'une vue\n+router.get('/add', function(req, res, next) {\n+\tvar accept = accepts(req);\n+\tswitch(accept.type(['html'])) {\n+\t\tcase 'html':\n+\t\t\tres.render('add');\n+\t\t\tbreak\n+\t\tdefault:\n+\t\t\tres.status(406).send({'error': 'Accepts incorrect. Content-type accpetés : text/html'});\n+\t\t\tbreak\n+\t}\n+\n+});\n+\n+\n+// Route GET/topPlaces : Retourne les 3 reviews qui ont le plus d'étoiles\n+router.get('/topPlaces', function(req, res, next) {\n+\tvar accept = accepts(req);\n+\tReviews.find({}).sort({stars: 'desc'}).limit(3).exec(function (err, reviews) {\n+\t\tif (err) {\n+\n+\t\t\tres.status(500).send({'error': err});\n+\n+\t\t} else {\n+\t\t\tswitch(accept.type(['html'])) {\n+\t\t\t\tcase 'html':\n+\t\t\t\t\tres.render('reviews', { reviews: reviews});\n+\t\t\t\t\tbreak\n+\t\t\t\tdefault:\n+\t\t\t\t\tres.status(406).send({'error': 'Accepts incorrect. Content-type accpetés : text/html'});\n+\t\t\t\t\tbreak\n+\t\t\t}\n+\n+\t\t}\n+\n+\t});\n+\n+});\n+\n+\n+// GET/search : Retourne la review cherchée\n+router.get('/search', function(req, res, next) {\n+\tvar accept = accepts(req);\n+\tif(Object.keys(req.query).length == 0) {\n+\t\tconsole.log('Ok');\n+\t\tres.status(200).render('search');\n+\n+\t} else {\n+\n+\t\tReviews.find(req.query, function (err, reviews) {\n+\n+\t\t\tif (err) {\n+\n+\t\t\t\tres.status(500).send({'error': err});\n+\n+\t\t\t} else if (reviews.length > 0) {\n+\t\t\t\tswitch(accept.type(['json', 'html'])) {\n+\t\t\t\t\tcase 'json':\n+\t\t\t\t\t\tres.send(reviews);\n+\t\t\t\t\t\tbreak\n+\t\t\t\t\tcase 'html':\n+\t\t\t\t\t\tres.render('reviews', { reviews: reviews});\n+\t\t\t\t\t\t\n+\t\t\t\t\t\tbreak\n+\t\t\t\t\tdefault:\n+\t\t\t\t\t\tres.status(406).send({'error': 'Accepts incorrect. Content-type accpetés : application/json, text/html'});\n+\t\t\t\t\t\tbreak\n+\t\t\t\t}\n+\n+\t\t\t}\n+\t\t\telse {\n+\n+\t\t\t\tres.status(404).send({message: \"Cette élément n'existe pas\"});\n+\n+\t\t\t}\n+\n+\t\t});\n+\n+\t}\n+\t\n+});\n+\n+\n+// Route GET : Retourne toute la liste des Reviews\n+router.get('/', function(req, res, next) {\n+\tvar accept = accepts(req);\n+\tReviews.find({}, function (err, reviews) {\n+\n+\t\tif (err) {\n+\n+\t\t\tres.status(500).send({'error': err});\n+\n+\t\t} else {\n+\t\t\tswitch(accept.type(['json', 'html'])) {\n+\t\t\t\tcase 'json':\n+\t\t\t\t\tres.send(reviews);\n+\t\t\t\t\tbreak\n+\t\t\t\tcase 'html':\n+\t\t\t\t\tres.render('reviews', { reviews: reviews});\n+\t\t\t\t\t\n+\t\t\t\t\tbreak\n+\t\t\t\tdefault:\n+\t\t\t\t\tres.status(406).send({'error': 'Accepts incorrect. Content-type accpetés : application/json, text/html'});\n+\t\t\t\t\tbreak\n+\t\t\t}\n+\n+\t\t}\n+\n+\t});\n+});\n+\n+\n+// Route POST : Stocke une nouvelle Review dans la liste\n+router.post('/', function(req, res, next) {\n+\tvar accept = accepts(req);\n+\tif (typeof req.body.name != \"undefined\" && typeof req.body.placeType != \"undefined\" && typeof req.body.stars != \"undefined\") {\n+\t\tReviews.create( {name: req.body.name, placeType: req.body.placeType, stars: req.body.stars}, function (err, review) {\n+\n+\t\t\tif (err) {\n+\n+\t\t\t\tres.status(500).send({'error': err});\n+\n+\t\t\t} else {\n+\n+\t\t\t\tswitch(accept.type(['json', 'html'])) {\n+\t\t\t\t\tcase 'json':\n+\t\t\t\t\t\tres.status(201).send(reviews);\n+\t\t\t\t\t\tbreak","path":"routes/reviews.js","position":134,"original_position":134,"commit_id":"d91f51e3b98e8cde435939c817d1af9eb2cc714d","original_commit_id":"d91f51e3b98e8cde435939c817d1af9eb2cc714d","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":"break**;** !!!!!!","created_at":"2015-03-24T18:24:40Z","updated_at":"2015-03-24T18:24:40Z","html_url":"https://github.com/RomainDeSaJardim/placeAdvisor/pull/1#discussion_r27058070","pull_request_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/comments/27058070"},"html":{"href":"https://github.com/RomainDeSaJardim/placeAdvisor/pull/1#discussion_r27058070"},"pull_request":{"href":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/1","id":31854569,"html_url":"https://github.com/RomainDeSaJardim/placeAdvisor/pull/1","diff_url":"https://github.com/RomainDeSaJardim/placeAdvisor/pull/1.diff","patch_url":"https://github.com/RomainDeSaJardim/placeAdvisor/pull/1.patch","issue_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/issues/1","number":1,"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 branche permettra d'afficher mes commentaires et corrections sur ton projet","created_at":"2015-03-24T18:12:31Z","updated_at":"2015-03-24T18:24:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9d02a1e8b646700911ed4264f49fa8988d57d69d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/1/commits","review_comments_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/1/comments","review_comment_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/issues/1/comments","statuses_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/statuses/d91f51e3b98e8cde435939c817d1af9eb2cc714d","head":{"label":"RomainDeSaJardim:TP3","ref":"TP3","sha":"d91f51e3b98e8cde435939c817d1af9eb2cc714d","user":{"login":"RomainDeSaJardim","id":8804888,"avatar_url":"https://avatars.githubusercontent.com/u/8804888?v=3","gravatar_id":"","url":"https://api.github.com/users/RomainDeSaJardim","html_url":"https://github.com/RomainDeSaJardim","followers_url":"https://api.github.com/users/RomainDeSaJardim/followers","following_url":"https://api.github.com/users/RomainDeSaJardim/following{/other_user}","gists_url":"https://api.github.com/users/RomainDeSaJardim/gists{/gist_id}","starred_url":"https://api.github.com/users/RomainDeSaJardim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomainDeSaJardim/subscriptions","organizations_url":"https://api.github.com/users/RomainDeSaJardim/orgs","repos_url":"https://api.github.com/users/RomainDeSaJardim/repos","events_url":"https://api.github.com/users/RomainDeSaJardim/events{/privacy}","received_events_url":"https://api.github.com/users/RomainDeSaJardim/received_events","type":"User","site_admin":false},"repo":{"id":31011876,"name":"placeAdvisor","full_name":"RomainDeSaJardim/placeAdvisor","owner":{"login":"RomainDeSaJardim","id":8804888,"avatar_url":"https://avatars.githubusercontent.com/u/8804888?v=3","gravatar_id":"","url":"https://api.github.com/users/RomainDeSaJardim","html_url":"https://github.com/RomainDeSaJardim","followers_url":"https://api.github.com/users/RomainDeSaJardim/followers","following_url":"https://api.github.com/users/RomainDeSaJardim/following{/other_user}","gists_url":"https://api.github.com/users/RomainDeSaJardim/gists{/gist_id}","starred_url":"https://api.github.com/users/RomainDeSaJardim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomainDeSaJardim/subscriptions","organizations_url":"https://api.github.com/users/RomainDeSaJardim/orgs","repos_url":"https://api.github.com/users/RomainDeSaJardim/repos","events_url":"https://api.github.com/users/RomainDeSaJardim/events{/privacy}","received_events_url":"https://api.github.com/users/RomainDeSaJardim/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RomainDeSaJardim/placeAdvisor","description":"Web Service","fork":false,"url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor","forks_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/forks","keys_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/teams","hooks_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/hooks","issue_events_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/issues/events{/number}","events_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/events","assignees_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/assignees{/user}","branches_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/branches{/branch}","tags_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/tags","blobs_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/git/refs{/sha}","trees_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/statuses/{sha}","languages_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/languages","stargazers_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/stargazers","contributors_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/contributors","subscribers_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/subscribers","subscription_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/subscription","commits_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/commits{/sha}","git_commits_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/git/commits{/sha}","comments_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/comments{/number}","issue_comment_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/issues/comments{/number}","contents_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/contents/{+path}","compare_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/merges","archive_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/downloads","issues_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/issues{/number}","pulls_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls{/number}","milestones_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/milestones{/number}","notifications_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/labels{/name}","releases_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/releases{/id}","created_at":"2015-02-19T11:10:58Z","updated_at":"2015-02-19T14:23:23Z","pushed_at":"2015-03-24T18:12:31Z","git_url":"git://github.com/RomainDeSaJardim/placeAdvisor.git","ssh_url":"git@github.com:RomainDeSaJardim/placeAdvisor.git","clone_url":"https://github.com/RomainDeSaJardim/placeAdvisor.git","svn_url":"https://github.com/RomainDeSaJardim/placeAdvisor","homepage":null,"size":176,"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":"TP1"}},"base":{"label":"RomainDeSaJardim:code-review","ref":"code-review","sha":"8c5233e646733adcc521312c498d5bef4b73d261","user":{"login":"RomainDeSaJardim","id":8804888,"avatar_url":"https://avatars.githubusercontent.com/u/8804888?v=3","gravatar_id":"","url":"https://api.github.com/users/RomainDeSaJardim","html_url":"https://github.com/RomainDeSaJardim","followers_url":"https://api.github.com/users/RomainDeSaJardim/followers","following_url":"https://api.github.com/users/RomainDeSaJardim/following{/other_user}","gists_url":"https://api.github.com/users/RomainDeSaJardim/gists{/gist_id}","starred_url":"https://api.github.com/users/RomainDeSaJardim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomainDeSaJardim/subscriptions","organizations_url":"https://api.github.com/users/RomainDeSaJardim/orgs","repos_url":"https://api.github.com/users/RomainDeSaJardim/repos","events_url":"https://api.github.com/users/RomainDeSaJardim/events{/privacy}","received_events_url":"https://api.github.com/users/RomainDeSaJardim/received_events","type":"User","site_admin":false},"repo":{"id":31011876,"name":"placeAdvisor","full_name":"RomainDeSaJardim/placeAdvisor","owner":{"login":"RomainDeSaJardim","id":8804888,"avatar_url":"https://avatars.githubusercontent.com/u/8804888?v=3","gravatar_id":"","url":"https://api.github.com/users/RomainDeSaJardim","html_url":"https://github.com/RomainDeSaJardim","followers_url":"https://api.github.com/users/RomainDeSaJardim/followers","following_url":"https://api.github.com/users/RomainDeSaJardim/following{/other_user}","gists_url":"https://api.github.com/users/RomainDeSaJardim/gists{/gist_id}","starred_url":"https://api.github.com/users/RomainDeSaJardim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomainDeSaJardim/subscriptions","organizations_url":"https://api.github.com/users/RomainDeSaJardim/orgs","repos_url":"https://api.github.com/users/RomainDeSaJardim/repos","events_url":"https://api.github.com/users/RomainDeSaJardim/events{/privacy}","received_events_url":"https://api.github.com/users/RomainDeSaJardim/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RomainDeSaJardim/placeAdvisor","description":"Web Service","fork":false,"url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor","forks_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/forks","keys_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/teams","hooks_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/hooks","issue_events_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/issues/events{/number}","events_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/events","assignees_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/assignees{/user}","branches_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/branches{/branch}","tags_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/tags","blobs_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/git/refs{/sha}","trees_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/statuses/{sha}","languages_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/languages","stargazers_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/stargazers","contributors_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/contributors","subscribers_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/subscribers","subscription_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/subscription","commits_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/commits{/sha}","git_commits_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/git/commits{/sha}","comments_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/comments{/number}","issue_comment_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/issues/comments{/number}","contents_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/contents/{+path}","compare_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/merges","archive_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/downloads","issues_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/issues{/number}","pulls_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls{/number}","milestones_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/milestones{/number}","notifications_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/labels{/name}","releases_url":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/releases{/id}","created_at":"2015-02-19T11:10:58Z","updated_at":"2015-02-19T14:23:23Z","pushed_at":"2015-03-24T18:12:31Z","git_url":"git://github.com/RomainDeSaJardim/placeAdvisor.git","ssh_url":"git@github.com:RomainDeSaJardim/placeAdvisor.git","clone_url":"https://github.com/RomainDeSaJardim/placeAdvisor.git","svn_url":"https://github.com/RomainDeSaJardim/placeAdvisor","homepage":null,"size":176,"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":"TP1"}},"_links":{"self":{"href":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/1"},"html":{"href":"https://github.com/RomainDeSaJardim/placeAdvisor/pull/1"},"issue":{"href":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/issues/1"},"comments":{"href":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/RomainDeSaJardim/placeAdvisor/statuses/d91f51e3b98e8cde435939c817d1af9eb2cc714d"}}}}