{"action":"created","comment":{"url":"https://api.github.com/repos/bitpay/insight-api/pulls/comments/62742821","id":62742821,"diff_hunk":"@@ -80,13 +84,43 @@ InsightAPI.prototype.getRoutePrefix = function() {\n };\n \n InsightAPI.prototype.start = function(callback) {\n-  this.node.services.bitcoind.on('tx', this.transactionHandler.bind(this));\n-\n+  this.node.services.bitcoind.on('tx', this.transactionEventHandler.bind(this));\n+  this.node.services.bitcoind.on('block', this.blockEventHandler.bind(this));\n   setImmediate(callback);\n };\n \n+InsightAPI.prototype.createLogInfoStream = function() {\n+  var self = this;\n+\n+  function Log(options) {\n+    Writable.call(this, options);\n+  }\n+  inherits(Log, Writable);\n+\n+  Log.prototype._write = function (chunk, enc, callback) {\n+    self.node.log.info(chunk.slice(0, chunk.length - 1)); // remove new line and pass to logger\n+    callback();\n+  };\n+  var stream = new Log();\n+\n+  return stream;\n+};\n+\n InsightAPI.prototype.setupRoutes = function(app) {\n \n+  //Enable rate limiter\n+  var limiter = new RateLimiter({node: this.node});\n+  app.use(limiter.middleware());\n+\n+  //Setup logging\n+  var logFormat = ':remote-addr \":method :url\" :status :res[content-length] :response-time \":user-agent\" ';\n+  var logStream = this.createLogInfoStream();\n+  app.use(morgan(logFormat, {stream: logStream}));\n+\n+  //Enable compression\n+  app.use(compression());","path":"lib/index.js","position":77,"original_position":67,"commit_id":"0ba78e7180b3c1a459065d76f54c7a2ed0a28c38","original_commit_id":"87643fba45d667d46185058912247a984b4b77d2","user":{"login":"braydonf","id":544777,"avatar_url":"https://avatars.githubusercontent.com/u/544777?v=3","gravatar_id":"","url":"https://api.github.com/users/braydonf","html_url":"https://github.com/braydonf","followers_url":"https://api.github.com/users/braydonf/followers","following_url":"https://api.github.com/users/braydonf/following{/other_user}","gists_url":"https://api.github.com/users/braydonf/gists{/gist_id}","starred_url":"https://api.github.com/users/braydonf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/braydonf/subscriptions","organizations_url":"https://api.github.com/users/braydonf/orgs","repos_url":"https://api.github.com/users/braydonf/repos","events_url":"https://api.github.com/users/braydonf/events{/privacy}","received_events_url":"https://api.github.com/users/braydonf/received_events","type":"User","site_admin":false},"body":"It's added in references to the prod2 branch: https://github.com/bitpay/insight-api/blob/prod2/config/express.js#L36 Though updated to use the latest version.","created_at":"2016-05-10T20:10:38Z","updated_at":"2016-05-10T20:10:38Z","html_url":"https://github.com/bitpay/insight-api/pull/467#discussion_r62742821","pull_request_url":"https://api.github.com/repos/bitpay/insight-api/pulls/467","_links":{"self":{"href":"https://api.github.com/repos/bitpay/insight-api/pulls/comments/62742821"},"html":{"href":"https://github.com/bitpay/insight-api/pull/467#discussion_r62742821"},"pull_request":{"href":"https://api.github.com/repos/bitpay/insight-api/pulls/467"}}},"pull_request":{"url":"https://api.github.com/repos/bitpay/insight-api/pulls/467","id":63767735,"html_url":"https://github.com/bitpay/insight-api/pull/467","diff_url":"https://github.com/bitpay/insight-api/pull/467.diff","patch_url":"https://github.com/bitpay/insight-api/pull/467.patch","issue_url":"https://api.github.com/repos/bitpay/insight-api/issues/467","number":467,"state":"open","locked":false,"title":"bitcoind address index","user":{"login":"braydonf","id":544777,"avatar_url":"https://avatars.githubusercontent.com/u/544777?v=3","gravatar_id":"","url":"https://api.github.com/users/braydonf","html_url":"https://github.com/braydonf","followers_url":"https://api.github.com/users/braydonf/followers","following_url":"https://api.github.com/users/braydonf/following{/other_user}","gists_url":"https://api.github.com/users/braydonf/gists{/gist_id}","starred_url":"https://api.github.com/users/braydonf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/braydonf/subscriptions","organizations_url":"https://api.github.com/users/braydonf/orgs","repos_url":"https://api.github.com/users/braydonf/repos","events_url":"https://api.github.com/users/braydonf/events{/privacy}","received_events_url":"https://api.github.com/users/braydonf/received_events","type":"User","site_admin":false},"body":"- API updates and changes for https://github.com/bitpay/bitcore-node/pull/422\r\n- Adds logging with `morgan` as similar to v0.2 https://github.com/bitpay/insight-api/tree/prod2\r\n- Adds basic ratelimiting based on https://github.com/bitpay/insight-api/tree/prod2\r\n- Adds LRU cache for block summary and transformed blocks\r\n- Adds compression\r\n- Adds new endpoint for `/rawblock/:blockArg` with height or hash https://github.com/bitpay/insight-api/issues/474\r\n- Fixes prevHash on genesis block issue https://github.com/bitpay/insight-api/issues/476\r\n- Optimizes block summary parsing merged from https://github.com/bitpay/insight-api/pull/469\r\n\r\n**Todo**:\r\n- [ ] Longer running test with typical API usage, especially with BWS\r\n- [ ] Test estimate fee with livenet\r\n- [ ] Express API compatibility with bitcore-node released version that includes changes in https://github.com/bitpay/bitcore-node/pull/422","created_at":"2016-03-22T18:16:28Z","updated_at":"2016-05-10T20:10:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ed8fe570f15efd696133e4fa4fd91260df7d721","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bitpay/insight-api/pulls/467/commits","review_comments_url":"https://api.github.com/repos/bitpay/insight-api/pulls/467/comments","review_comment_url":"https://api.github.com/repos/bitpay/insight-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bitpay/insight-api/issues/467/comments","statuses_url":"https://api.github.com/repos/bitpay/insight-api/statuses/0ba78e7180b3c1a459065d76f54c7a2ed0a28c38","head":{"label":"braydonf:bitcoind","ref":"bitcoind","sha":"0ba78e7180b3c1a459065d76f54c7a2ed0a28c38","user":{"login":"braydonf","id":544777,"avatar_url":"https://avatars.githubusercontent.com/u/544777?v=3","gravatar_id":"","url":"https://api.github.com/users/braydonf","html_url":"https://github.com/braydonf","followers_url":"https://api.github.com/users/braydonf/followers","following_url":"https://api.github.com/users/braydonf/following{/other_user}","gists_url":"https://api.github.com/users/braydonf/gists{/gist_id}","starred_url":"https://api.github.com/users/braydonf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/braydonf/subscriptions","organizations_url":"https://api.github.com/users/braydonf/orgs","repos_url":"https://api.github.com/users/braydonf/repos","events_url":"https://api.github.com/users/braydonf/events{/privacy}","received_events_url":"https://api.github.com/users/braydonf/received_events","type":"User","site_admin":false},"repo":{"id":41809603,"name":"insight-api","full_name":"braydonf/insight-api","owner":{"login":"braydonf","id":544777,"avatar_url":"https://avatars.githubusercontent.com/u/544777?v=3","gravatar_id":"","url":"https://api.github.com/users/braydonf","html_url":"https://github.com/braydonf","followers_url":"https://api.github.com/users/braydonf/followers","following_url":"https://api.github.com/users/braydonf/following{/other_user}","gists_url":"https://api.github.com/users/braydonf/gists{/gist_id}","starred_url":"https://api.github.com/users/braydonf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/braydonf/subscriptions","organizations_url":"https://api.github.com/users/braydonf/orgs","repos_url":"https://api.github.com/users/braydonf/repos","events_url":"https://api.github.com/users/braydonf/events{/privacy}","received_events_url":"https://api.github.com/users/braydonf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/braydonf/insight-api","description":"A bitcoin blockchain API for web wallets","fork":true,"url":"https://api.github.com/repos/braydonf/insight-api","forks_url":"https://api.github.com/repos/braydonf/insight-api/forks","keys_url":"https://api.github.com/repos/braydonf/insight-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/braydonf/insight-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/braydonf/insight-api/teams","hooks_url":"https://api.github.com/repos/braydonf/insight-api/hooks","issue_events_url":"https://api.github.com/repos/braydonf/insight-api/issues/events{/number}","events_url":"https://api.github.com/repos/braydonf/insight-api/events","assignees_url":"https://api.github.com/repos/braydonf/insight-api/assignees{/user}","branches_url":"https://api.github.com/repos/braydonf/insight-api/branches{/branch}","tags_url":"https://api.github.com/repos/braydonf/insight-api/tags","blobs_url":"https://api.github.com/repos/braydonf/insight-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/braydonf/insight-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/braydonf/insight-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/braydonf/insight-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/braydonf/insight-api/statuses/{sha}","languages_url":"https://api.github.com/repos/braydonf/insight-api/languages","stargazers_url":"https://api.github.com/repos/braydonf/insight-api/stargazers","contributors_url":"https://api.github.com/repos/braydonf/insight-api/contributors","subscribers_url":"https://api.github.com/repos/braydonf/insight-api/subscribers","subscription_url":"https://api.github.com/repos/braydonf/insight-api/subscription","commits_url":"https://api.github.com/repos/braydonf/insight-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/braydonf/insight-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/braydonf/insight-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/braydonf/insight-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/braydonf/insight-api/contents/{+path}","compare_url":"https://api.github.com/repos/braydonf/insight-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/braydonf/insight-api/merges","archive_url":"https://api.github.com/repos/braydonf/insight-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/braydonf/insight-api/downloads","issues_url":"https://api.github.com/repos/braydonf/insight-api/issues{/number}","pulls_url":"https://api.github.com/repos/braydonf/insight-api/pulls{/number}","milestones_url":"https://api.github.com/repos/braydonf/insight-api/milestones{/number}","notifications_url":"https://api.github.com/repos/braydonf/insight-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/braydonf/insight-api/labels{/name}","releases_url":"https://api.github.com/repos/braydonf/insight-api/releases{/id}","deployments_url":"https://api.github.com/repos/braydonf/insight-api/deployments","created_at":"2015-09-02T15:31:33Z","updated_at":"2015-09-02T15:31:33Z","pushed_at":"2016-05-10T19:58:01Z","git_url":"git://github.com/braydonf/insight-api.git","ssh_url":"git@github.com:braydonf/insight-api.git","clone_url":"https://github.com/braydonf/insight-api.git","svn_url":"https://github.com/braydonf/insight-api","homepage":"http://insight.is/","size":2816,"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":"bitpay:master","ref":"master","sha":"133c2321f950445b177d1d4b150680637a741b3d","user":{"login":"bitpay","id":2554930,"avatar_url":"https://avatars.githubusercontent.com/u/2554930?v=3","gravatar_id":"","url":"https://api.github.com/users/bitpay","html_url":"https://github.com/bitpay","followers_url":"https://api.github.com/users/bitpay/followers","following_url":"https://api.github.com/users/bitpay/following{/other_user}","gists_url":"https://api.github.com/users/bitpay/gists{/gist_id}","starred_url":"https://api.github.com/users/bitpay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitpay/subscriptions","organizations_url":"https://api.github.com/users/bitpay/orgs","repos_url":"https://api.github.com/users/bitpay/repos","events_url":"https://api.github.com/users/bitpay/events{/privacy}","received_events_url":"https://api.github.com/users/bitpay/received_events","type":"Organization","site_admin":false},"repo":{"id":17212410,"name":"insight-api","full_name":"bitpay/insight-api","owner":{"login":"bitpay","id":2554930,"avatar_url":"https://avatars.githubusercontent.com/u/2554930?v=3","gravatar_id":"","url":"https://api.github.com/users/bitpay","html_url":"https://github.com/bitpay","followers_url":"https://api.github.com/users/bitpay/followers","following_url":"https://api.github.com/users/bitpay/following{/other_user}","gists_url":"https://api.github.com/users/bitpay/gists{/gist_id}","starred_url":"https://api.github.com/users/bitpay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitpay/subscriptions","organizations_url":"https://api.github.com/users/bitpay/orgs","repos_url":"https://api.github.com/users/bitpay/repos","events_url":"https://api.github.com/users/bitpay/events{/privacy}","received_events_url":"https://api.github.com/users/bitpay/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bitpay/insight-api","description":"A bitcoin blockchain API for web wallets","fork":false,"url":"https://api.github.com/repos/bitpay/insight-api","forks_url":"https://api.github.com/repos/bitpay/insight-api/forks","keys_url":"https://api.github.com/repos/bitpay/insight-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bitpay/insight-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bitpay/insight-api/teams","hooks_url":"https://api.github.com/repos/bitpay/insight-api/hooks","issue_events_url":"https://api.github.com/repos/bitpay/insight-api/issues/events{/number}","events_url":"https://api.github.com/repos/bitpay/insight-api/events","assignees_url":"https://api.github.com/repos/bitpay/insight-api/assignees{/user}","branches_url":"https://api.github.com/repos/bitpay/insight-api/branches{/branch}","tags_url":"https://api.github.com/repos/bitpay/insight-api/tags","blobs_url":"https://api.github.com/repos/bitpay/insight-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bitpay/insight-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bitpay/insight-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/bitpay/insight-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bitpay/insight-api/statuses/{sha}","languages_url":"https://api.github.com/repos/bitpay/insight-api/languages","stargazers_url":"https://api.github.com/repos/bitpay/insight-api/stargazers","contributors_url":"https://api.github.com/repos/bitpay/insight-api/contributors","subscribers_url":"https://api.github.com/repos/bitpay/insight-api/subscribers","subscription_url":"https://api.github.com/repos/bitpay/insight-api/subscription","commits_url":"https://api.github.com/repos/bitpay/insight-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/bitpay/insight-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/bitpay/insight-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/bitpay/insight-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/bitpay/insight-api/contents/{+path}","compare_url":"https://api.github.com/repos/bitpay/insight-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bitpay/insight-api/merges","archive_url":"https://api.github.com/repos/bitpay/insight-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bitpay/insight-api/downloads","issues_url":"https://api.github.com/repos/bitpay/insight-api/issues{/number}","pulls_url":"https://api.github.com/repos/bitpay/insight-api/pulls{/number}","milestones_url":"https://api.github.com/repos/bitpay/insight-api/milestones{/number}","notifications_url":"https://api.github.com/repos/bitpay/insight-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bitpay/insight-api/labels{/name}","releases_url":"https://api.github.com/repos/bitpay/insight-api/releases{/id}","deployments_url":"https://api.github.com/repos/bitpay/insight-api/deployments","created_at":"2014-02-26T14:04:59Z","updated_at":"2016-05-01T08:09:00Z","pushed_at":"2016-05-10T19:58:02Z","git_url":"git://github.com/bitpay/insight-api.git","ssh_url":"git@github.com:bitpay/insight-api.git","clone_url":"https://github.com/bitpay/insight-api.git","svn_url":"https://github.com/bitpay/insight-api","homepage":"http://insight.is/","size":3515,"stargazers_count":191,"watchers_count":191,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":282,"mirror_url":null,"open_issues_count":92,"forks":282,"open_issues":92,"watchers":191,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bitpay/insight-api/pulls/467"},"html":{"href":"https://github.com/bitpay/insight-api/pull/467"},"issue":{"href":"https://api.github.com/repos/bitpay/insight-api/issues/467"},"comments":{"href":"https://api.github.com/repos/bitpay/insight-api/issues/467/comments"},"review_comments":{"href":"https://api.github.com/repos/bitpay/insight-api/pulls/467/comments"},"review_comment":{"href":"https://api.github.com/repos/bitpay/insight-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bitpay/insight-api/pulls/467/commits"},"statuses":{"href":"https://api.github.com/repos/bitpay/insight-api/statuses/0ba78e7180b3c1a459065d76f54c7a2ed0a28c38"}}}}