{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/comments/85490209","pull_request_review_id":6201285,"id":85490209,"diff_hunk":"@@ -47,8 +56,74 @@ let router = express.Router();\n  * }\n  **/\n \n-router.get('/Things', (req, res) => {\n-  res.status(200).send();\n+const resource = 'Things';\n+\n+router.get('/', (req, res) => {\n+  db().then((models) => {\n+    if (req.params && req.params[0]) {\n+      models.Things.findById(req.params[0]).then(thing => {\n+        res.status(200).send(response.generate(thing));\n+      });\n+    } else {\n+      models.Things.findAll().then(things => {\n+        res.status(200).send(response.generate(things));\n+      });\n+    }\n+  })\n+  .catch(() => {\n+    ApiError(res, 500, ERRNO_INTERNAL_ERROR, INTERNAL_ERROR);\n+  });\n+});\n+\n+router.post('/', (req, res) => {\n+  db().then((models) => {\n+    models.Things.create(req.body)\n+    .then(createdThing => {\n+      res.location('/' + resource + '/' + createdThing.id);\n+      res.status(201).send();\n+    })\n+    .catch(() => {\n+      res.status(400).send();\n+    });\n+  });\n+});\n+\n+router.patch('/', (req, res) => {\n+  if (!req.params || !req.params[0]) {\n+    ApiError(res, 404, ERRNO_RESOURCE_NOT_FOUND, BAD_REQUEST);\n+\n+    return;\n+  }\n+\n+  db().then((models) => {\n+    models.Things.findById(req.params[0]).then(thing => {\n+      thing.update(req.body).then(updatedThing => {\n+        res.status(200).send(response.generate(updatedThing));\n+      });\n+    });\n+  });\n+});\n+\n+router.delete('/', (req, res) => {\n+  if (!req.params || !req.params[0]) {\n+    ApiError(res, 404, ERRNO_RESOURCE_NOT_FOUND, BAD_REQUEST);\n+\n+    return;\n+  }\n+\n+  db().then((models) => {\n+    models.Things.findById(req.params[0]).then(thing => {\n+      thing.destroy().then(() => {\n+        res.status(204).send();\n+      })\n+      .catch(() => {\n+        ApiError(res, 500, ERRNO_INTERNAL_ERROR, INTERNAL_ERROR);\n+      });\n+    })\n+    .catch(() => {\n+      ApiError(res, 500, ERRNO_INTERNAL_ERROR, INTERNAL_ERROR);","path":"src/routes/things.js","position":89,"original_position":89,"commit_id":"866123b7833f75fccf479695651a05eb88073c36","original_commit_id":"866123b7833f75fccf479695651a05eb88073c36","user":{"login":"ferjm","id":480202,"avatar_url":"https://avatars.githubusercontent.com/u/480202?v=3","gravatar_id":"","url":"https://api.github.com/users/ferjm","html_url":"https://github.com/ferjm","followers_url":"https://api.github.com/users/ferjm/followers","following_url":"https://api.github.com/users/ferjm/following{/other_user}","gists_url":"https://api.github.com/users/ferjm/gists{/gist_id}","starred_url":"https://api.github.com/users/ferjm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferjm/subscriptions","organizations_url":"https://api.github.com/users/ferjm/orgs","repos_url":"https://api.github.com/users/ferjm/repos","events_url":"https://api.github.com/users/ferjm/events{/privacy}","received_events_url":"https://api.github.com/users/ferjm/received_events","type":"User","site_admin":false},"body":"Does this happen when the id is not found? In that case, this should be a 404.","created_at":"2016-10-28T08:27:01Z","updated_at":"2016-10-28T08:35:24Z","html_url":"https://github.com/mozilla-sensorweb/sensorthings/pull/4#discussion_r85490209","pull_request_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/comments/85490209"},"html":{"href":"https://github.com/mozilla-sensorweb/sensorthings/pull/4#discussion_r85490209"},"pull_request":{"href":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/4","id":90833583,"html_url":"https://github.com/mozilla-sensorweb/sensorthings/pull/4","diff_url":"https://github.com/mozilla-sensorweb/sensorthings/pull/4.diff","patch_url":"https://github.com/mozilla-sensorweb/sensorthings/pull/4.patch","issue_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/issues/4","number":4,"state":"open","locked":false,"title":"Things endpoint","user":{"login":"albertopq","id":368225,"avatar_url":"https://avatars.githubusercontent.com/u/368225?v=3","gravatar_id":"","url":"https://api.github.com/users/albertopq","html_url":"https://github.com/albertopq","followers_url":"https://api.github.com/users/albertopq/followers","following_url":"https://api.github.com/users/albertopq/following{/other_user}","gists_url":"https://api.github.com/users/albertopq/gists{/gist_id}","starred_url":"https://api.github.com/users/albertopq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertopq/subscriptions","organizations_url":"https://api.github.com/users/albertopq/orgs","repos_url":"https://api.github.com/users/albertopq/repos","events_url":"https://api.github.com/users/albertopq/events{/privacy}","received_events_url":"https://api.github.com/users/albertopq/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-25T15:36:20Z","updated_at":"2016-10-28T08:35:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e398e42405875e1f89eff1dc354eb3b0f881ca04","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/4/commits","review_comments_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/4/comments","review_comment_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/issues/4/comments","statuses_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/statuses/866123b7833f75fccf479695651a05eb88073c36","head":{"label":"albertopq:endpoints-things","ref":"endpoints-things","sha":"866123b7833f75fccf479695651a05eb88073c36","user":{"login":"albertopq","id":368225,"avatar_url":"https://avatars.githubusercontent.com/u/368225?v=3","gravatar_id":"","url":"https://api.github.com/users/albertopq","html_url":"https://github.com/albertopq","followers_url":"https://api.github.com/users/albertopq/followers","following_url":"https://api.github.com/users/albertopq/following{/other_user}","gists_url":"https://api.github.com/users/albertopq/gists{/gist_id}","starred_url":"https://api.github.com/users/albertopq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertopq/subscriptions","organizations_url":"https://api.github.com/users/albertopq/orgs","repos_url":"https://api.github.com/users/albertopq/repos","events_url":"https://api.github.com/users/albertopq/events{/privacy}","received_events_url":"https://api.github.com/users/albertopq/received_events","type":"User","site_admin":false},"repo":{"id":71449808,"name":"sensorthings","full_name":"albertopq/sensorthings","owner":{"login":"albertopq","id":368225,"avatar_url":"https://avatars.githubusercontent.com/u/368225?v=3","gravatar_id":"","url":"https://api.github.com/users/albertopq","html_url":"https://github.com/albertopq","followers_url":"https://api.github.com/users/albertopq/followers","following_url":"https://api.github.com/users/albertopq/following{/other_user}","gists_url":"https://api.github.com/users/albertopq/gists{/gist_id}","starred_url":"https://api.github.com/users/albertopq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertopq/subscriptions","organizations_url":"https://api.github.com/users/albertopq/orgs","repos_url":"https://api.github.com/users/albertopq/repos","events_url":"https://api.github.com/users/albertopq/events{/privacy}","received_events_url":"https://api.github.com/users/albertopq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/albertopq/sensorthings","description":"Node implementation of the OGC SensorThings API","fork":true,"url":"https://api.github.com/repos/albertopq/sensorthings","forks_url":"https://api.github.com/repos/albertopq/sensorthings/forks","keys_url":"https://api.github.com/repos/albertopq/sensorthings/keys{/key_id}","collaborators_url":"https://api.github.com/repos/albertopq/sensorthings/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/albertopq/sensorthings/teams","hooks_url":"https://api.github.com/repos/albertopq/sensorthings/hooks","issue_events_url":"https://api.github.com/repos/albertopq/sensorthings/issues/events{/number}","events_url":"https://api.github.com/repos/albertopq/sensorthings/events","assignees_url":"https://api.github.com/repos/albertopq/sensorthings/assignees{/user}","branches_url":"https://api.github.com/repos/albertopq/sensorthings/branches{/branch}","tags_url":"https://api.github.com/repos/albertopq/sensorthings/tags","blobs_url":"https://api.github.com/repos/albertopq/sensorthings/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/albertopq/sensorthings/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/albertopq/sensorthings/git/refs{/sha}","trees_url":"https://api.github.com/repos/albertopq/sensorthings/git/trees{/sha}","statuses_url":"https://api.github.com/repos/albertopq/sensorthings/statuses/{sha}","languages_url":"https://api.github.com/repos/albertopq/sensorthings/languages","stargazers_url":"https://api.github.com/repos/albertopq/sensorthings/stargazers","contributors_url":"https://api.github.com/repos/albertopq/sensorthings/contributors","subscribers_url":"https://api.github.com/repos/albertopq/sensorthings/subscribers","subscription_url":"https://api.github.com/repos/albertopq/sensorthings/subscription","commits_url":"https://api.github.com/repos/albertopq/sensorthings/commits{/sha}","git_commits_url":"https://api.github.com/repos/albertopq/sensorthings/git/commits{/sha}","comments_url":"https://api.github.com/repos/albertopq/sensorthings/comments{/number}","issue_comment_url":"https://api.github.com/repos/albertopq/sensorthings/issues/comments{/number}","contents_url":"https://api.github.com/repos/albertopq/sensorthings/contents/{+path}","compare_url":"https://api.github.com/repos/albertopq/sensorthings/compare/{base}...{head}","merges_url":"https://api.github.com/repos/albertopq/sensorthings/merges","archive_url":"https://api.github.com/repos/albertopq/sensorthings/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/albertopq/sensorthings/downloads","issues_url":"https://api.github.com/repos/albertopq/sensorthings/issues{/number}","pulls_url":"https://api.github.com/repos/albertopq/sensorthings/pulls{/number}","milestones_url":"https://api.github.com/repos/albertopq/sensorthings/milestones{/number}","notifications_url":"https://api.github.com/repos/albertopq/sensorthings/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/albertopq/sensorthings/labels{/name}","releases_url":"https://api.github.com/repos/albertopq/sensorthings/releases{/id}","deployments_url":"https://api.github.com/repos/albertopq/sensorthings/deployments","created_at":"2016-10-20T09:59:23Z","updated_at":"2016-10-20T09:59:25Z","pushed_at":"2016-10-27T14:18:36Z","git_url":"git://github.com/albertopq/sensorthings.git","ssh_url":"git@github.com:albertopq/sensorthings.git","clone_url":"https://github.com/albertopq/sensorthings.git","svn_url":"https://github.com/albertopq/sensorthings","homepage":null,"size":38,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla-sensorweb:master","ref":"master","sha":"58c35bd74f4f4f69385713683290518e2ef52642","user":{"login":"mozilla-sensorweb","id":22178992,"avatar_url":"https://avatars.githubusercontent.com/u/22178992?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-sensorweb","html_url":"https://github.com/mozilla-sensorweb","followers_url":"https://api.github.com/users/mozilla-sensorweb/followers","following_url":"https://api.github.com/users/mozilla-sensorweb/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-sensorweb/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-sensorweb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-sensorweb/subscriptions","organizations_url":"https://api.github.com/users/mozilla-sensorweb/orgs","repos_url":"https://api.github.com/users/mozilla-sensorweb/repos","events_url":"https://api.github.com/users/mozilla-sensorweb/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-sensorweb/received_events","type":"Organization","site_admin":false},"repo":{"id":71230782,"name":"sensorthings","full_name":"mozilla-sensorweb/sensorthings","owner":{"login":"mozilla-sensorweb","id":22178992,"avatar_url":"https://avatars.githubusercontent.com/u/22178992?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-sensorweb","html_url":"https://github.com/mozilla-sensorweb","followers_url":"https://api.github.com/users/mozilla-sensorweb/followers","following_url":"https://api.github.com/users/mozilla-sensorweb/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-sensorweb/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-sensorweb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-sensorweb/subscriptions","organizations_url":"https://api.github.com/users/mozilla-sensorweb/orgs","repos_url":"https://api.github.com/users/mozilla-sensorweb/repos","events_url":"https://api.github.com/users/mozilla-sensorweb/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-sensorweb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-sensorweb/sensorthings","description":"Node implementation of the OGC SensorThings API","fork":false,"url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings","forks_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/forks","keys_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/teams","hooks_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/hooks","issue_events_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/events","assignees_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/tags","blobs_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/languages","stargazers_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/stargazers","contributors_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/contributors","subscribers_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/subscribers","subscription_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/subscription","commits_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/merges","archive_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/downloads","issues_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/deployments","created_at":"2016-10-18T09:19:22Z","updated_at":"2016-10-18T14:37:54Z","pushed_at":"2016-10-28T08:06:00Z","git_url":"git://github.com/mozilla-sensorweb/sensorthings.git","ssh_url":"git@github.com:mozilla-sensorweb/sensorthings.git","clone_url":"https://github.com/mozilla-sensorweb/sensorthings.git","svn_url":"https://github.com/mozilla-sensorweb/sensorthings","homepage":null,"size":49,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/4"},"html":{"href":"https://github.com/mozilla-sensorweb/sensorthings/pull/4"},"issue":{"href":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/issues/4"},"comments":{"href":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-sensorweb/sensorthings/statuses/866123b7833f75fccf479695651a05eb88073c36"}}}}
{"actor":{"display_login":"ferjm"}}