{"action":"created","comment":{"url":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/comments/68023664","id":68023664,"diff_hunk":"@@ -0,0 +1,23 @@\n+const fetchres = require('fetchres');\n+const isFastFT = url => url.indexOf('NTlhNzEyMzMtZjBjZi00Y2U1LTg0ODUtZWVjNmEyYmU1NzQ2-QnJhbmRz') !== -1;\n+\n+module.exports = (req, res, next) => {\n+\tif (req.query.p && isFastFT(req.url)) {\n+\t\tconst url = `http://www.ft.com/fastft/api/get_post/?id=${req.query.p}&api_key=${process.env.BLOGS_API_KEY}`;\n+\t\treturn fetch(url, {\n+\t\t\t\ttimeout: 500\n+\t\t\t})\n+\t\t\t.then(fetchres.json)\n+\t\t\t.then(data => {\n+\t\t\t\tif (data && data.status && data.status === 'ok' && data.post && data.post.url) {\n+\t\t\t\t\tres.redirect(302, data.post.url);\n+\t\t\t\t\tres.end();\n+\t\t\t\t} else {\n+\t\t\t\t\tnext();\n+\t\t\t\t}\n+\t\t\t})\n+\t\t\t.catch(next)","path":"server/middleware/blogs-permalink.js","position":19,"original_position":19,"commit_id":"7127881e22f5268e2515f7b8bf02c5bc4abf965c","original_commit_id":"7127881e22f5268e2515f7b8bf02c5bc4abf965c","user":{"login":"bjfletcher","id":733849,"avatar_url":"https://avatars.githubusercontent.com/u/733849?v=3","gravatar_id":"","url":"https://api.github.com/users/bjfletcher","html_url":"https://github.com/bjfletcher","followers_url":"https://api.github.com/users/bjfletcher/followers","following_url":"https://api.github.com/users/bjfletcher/following{/other_user}","gists_url":"https://api.github.com/users/bjfletcher/gists{/gist_id}","starred_url":"https://api.github.com/users/bjfletcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjfletcher/subscriptions","organizations_url":"https://api.github.com/users/bjfletcher/orgs","repos_url":"https://api.github.com/users/bjfletcher/repos","events_url":"https://api.github.com/users/bjfletcher/events{/privacy}","received_events_url":"https://api.github.com/users/bjfletcher/received_events","type":"User","site_admin":false},"body":"why running `next()` when there's an error?","created_at":"2016-06-22T09:44:29Z","updated_at":"2016-06-22T09:44:29Z","html_url":"https://github.com/Financial-Times/next-stream-page/pull/1156#discussion_r68023664","pull_request_url":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/1156","_links":{"self":{"href":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/comments/68023664"},"html":{"href":"https://github.com/Financial-Times/next-stream-page/pull/1156#discussion_r68023664"},"pull_request":{"href":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/1156"}}},"pull_request":{"url":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/1156","id":74463290,"html_url":"https://github.com/Financial-Times/next-stream-page/pull/1156","diff_url":"https://github.com/Financial-Times/next-stream-page/pull/1156.diff","patch_url":"https://github.com/Financial-Times/next-stream-page/pull/1156.patch","issue_url":"https://api.github.com/repos/Financial-Times/next-stream-page/issues/1156","number":1156,"state":"open","locked":false,"title":"add middleware to detect if permalink parameter has been passed. if s…","user":{"login":"VladDubrovskis","id":15323495,"avatar_url":"https://avatars.githubusercontent.com/u/15323495?v=3","gravatar_id":"","url":"https://api.github.com/users/VladDubrovskis","html_url":"https://github.com/VladDubrovskis","followers_url":"https://api.github.com/users/VladDubrovskis/followers","following_url":"https://api.github.com/users/VladDubrovskis/following{/other_user}","gists_url":"https://api.github.com/users/VladDubrovskis/gists{/gist_id}","starred_url":"https://api.github.com/users/VladDubrovskis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladDubrovskis/subscriptions","organizations_url":"https://api.github.com/users/VladDubrovskis/orgs","repos_url":"https://api.github.com/users/VladDubrovskis/repos","events_url":"https://api.github.com/users/VladDubrovskis/events{/privacy}","received_events_url":"https://api.github.com/users/VladDubrovskis/received_events","type":"User","site_admin":false},"body":"…o, get url and redirect\r\n/cc @andygnewman @bjfletcher \r\n\r\nLet me know your thoughts on this one, now that I have done it not too sure if middleware was best place for it, but theoretically it is quite hight up on request chain to redirect before hitting the rest of the application?","created_at":"2016-06-20T15:31:54Z","updated_at":"2016-06-22T09:44:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8097d8274479aaf973e6901681b3a25cf9715b4d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/1156/commits","review_comments_url":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/1156/comments","review_comment_url":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Financial-Times/next-stream-page/issues/1156/comments","statuses_url":"https://api.github.com/repos/Financial-Times/next-stream-page/statuses/7127881e22f5268e2515f7b8bf02c5bc4abf965c","head":{"label":"Financial-Times:blogs-permalink-fix","ref":"blogs-permalink-fix","sha":"7127881e22f5268e2515f7b8bf02c5bc4abf965c","user":{"login":"Financial-Times","id":3502508,"avatar_url":"https://avatars.githubusercontent.com/u/3502508?v=3","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"repo":{"id":24595604,"name":"next-stream-page","full_name":"Financial-Times/next-stream-page","owner":{"login":"Financial-Times","id":3502508,"avatar_url":"https://avatars.githubusercontent.com/u/3502508?v=3","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Financial-Times/next-stream-page","description":"Streams","fork":false,"url":"https://api.github.com/repos/Financial-Times/next-stream-page","forks_url":"https://api.github.com/repos/Financial-Times/next-stream-page/forks","keys_url":"https://api.github.com/repos/Financial-Times/next-stream-page/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Financial-Times/next-stream-page/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Financial-Times/next-stream-page/teams","hooks_url":"https://api.github.com/repos/Financial-Times/next-stream-page/hooks","issue_events_url":"https://api.github.com/repos/Financial-Times/next-stream-page/issues/events{/number}","events_url":"https://api.github.com/repos/Financial-Times/next-stream-page/events","assignees_url":"https://api.github.com/repos/Financial-Times/next-stream-page/assignees{/user}","branches_url":"https://api.github.com/repos/Financial-Times/next-stream-page/branches{/branch}","tags_url":"https://api.github.com/repos/Financial-Times/next-stream-page/tags","blobs_url":"https://api.github.com/repos/Financial-Times/next-stream-page/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Financial-Times/next-stream-page/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Financial-Times/next-stream-page/git/refs{/sha}","trees_url":"https://api.github.com/repos/Financial-Times/next-stream-page/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Financial-Times/next-stream-page/statuses/{sha}","languages_url":"https://api.github.com/repos/Financial-Times/next-stream-page/languages","stargazers_url":"https://api.github.com/repos/Financial-Times/next-stream-page/stargazers","contributors_url":"https://api.github.com/repos/Financial-Times/next-stream-page/contributors","subscribers_url":"https://api.github.com/repos/Financial-Times/next-stream-page/subscribers","subscription_url":"https://api.github.com/repos/Financial-Times/next-stream-page/subscription","commits_url":"https://api.github.com/repos/Financial-Times/next-stream-page/commits{/sha}","git_commits_url":"https://api.github.com/repos/Financial-Times/next-stream-page/git/commits{/sha}","comments_url":"https://api.github.com/repos/Financial-Times/next-stream-page/comments{/number}","issue_comment_url":"https://api.github.com/repos/Financial-Times/next-stream-page/issues/comments{/number}","contents_url":"https://api.github.com/repos/Financial-Times/next-stream-page/contents/{+path}","compare_url":"https://api.github.com/repos/Financial-Times/next-stream-page/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Financial-Times/next-stream-page/merges","archive_url":"https://api.github.com/repos/Financial-Times/next-stream-page/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Financial-Times/next-stream-page/downloads","issues_url":"https://api.github.com/repos/Financial-Times/next-stream-page/issues{/number}","pulls_url":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls{/number}","milestones_url":"https://api.github.com/repos/Financial-Times/next-stream-page/milestones{/number}","notifications_url":"https://api.github.com/repos/Financial-Times/next-stream-page/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Financial-Times/next-stream-page/labels{/name}","releases_url":"https://api.github.com/repos/Financial-Times/next-stream-page/releases{/id}","deployments_url":"https://api.github.com/repos/Financial-Times/next-stream-page/deployments","created_at":"2014-09-29T13:09:59Z","updated_at":"2016-04-05T10:02:31Z","pushed_at":"2016-06-22T08:45:48Z","git_url":"git://github.com/Financial-Times/next-stream-page.git","ssh_url":"git@github.com:Financial-Times/next-stream-page.git","clone_url":"https://github.com/Financial-Times/next-stream-page.git","svn_url":"https://github.com/Financial-Times/next-stream-page","homepage":"","size":7501,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":20,"forks":2,"open_issues":20,"watchers":2,"default_branch":"master"}},"base":{"label":"Financial-Times:master","ref":"master","sha":"fa0f586d781ea6ce458eb331489355c52ac4ba49","user":{"login":"Financial-Times","id":3502508,"avatar_url":"https://avatars.githubusercontent.com/u/3502508?v=3","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"repo":{"id":24595604,"name":"next-stream-page","full_name":"Financial-Times/next-stream-page","owner":{"login":"Financial-Times","id":3502508,"avatar_url":"https://avatars.githubusercontent.com/u/3502508?v=3","gravatar_id":"","url":"https://api.github.com/users/Financial-Times","html_url":"https://github.com/Financial-Times","followers_url":"https://api.github.com/users/Financial-Times/followers","following_url":"https://api.github.com/users/Financial-Times/following{/other_user}","gists_url":"https://api.github.com/users/Financial-Times/gists{/gist_id}","starred_url":"https://api.github.com/users/Financial-Times/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Financial-Times/subscriptions","organizations_url":"https://api.github.com/users/Financial-Times/orgs","repos_url":"https://api.github.com/users/Financial-Times/repos","events_url":"https://api.github.com/users/Financial-Times/events{/privacy}","received_events_url":"https://api.github.com/users/Financial-Times/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Financial-Times/next-stream-page","description":"Streams","fork":false,"url":"https://api.github.com/repos/Financial-Times/next-stream-page","forks_url":"https://api.github.com/repos/Financial-Times/next-stream-page/forks","keys_url":"https://api.github.com/repos/Financial-Times/next-stream-page/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Financial-Times/next-stream-page/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Financial-Times/next-stream-page/teams","hooks_url":"https://api.github.com/repos/Financial-Times/next-stream-page/hooks","issue_events_url":"https://api.github.com/repos/Financial-Times/next-stream-page/issues/events{/number}","events_url":"https://api.github.com/repos/Financial-Times/next-stream-page/events","assignees_url":"https://api.github.com/repos/Financial-Times/next-stream-page/assignees{/user}","branches_url":"https://api.github.com/repos/Financial-Times/next-stream-page/branches{/branch}","tags_url":"https://api.github.com/repos/Financial-Times/next-stream-page/tags","blobs_url":"https://api.github.com/repos/Financial-Times/next-stream-page/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Financial-Times/next-stream-page/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Financial-Times/next-stream-page/git/refs{/sha}","trees_url":"https://api.github.com/repos/Financial-Times/next-stream-page/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Financial-Times/next-stream-page/statuses/{sha}","languages_url":"https://api.github.com/repos/Financial-Times/next-stream-page/languages","stargazers_url":"https://api.github.com/repos/Financial-Times/next-stream-page/stargazers","contributors_url":"https://api.github.com/repos/Financial-Times/next-stream-page/contributors","subscribers_url":"https://api.github.com/repos/Financial-Times/next-stream-page/subscribers","subscription_url":"https://api.github.com/repos/Financial-Times/next-stream-page/subscription","commits_url":"https://api.github.com/repos/Financial-Times/next-stream-page/commits{/sha}","git_commits_url":"https://api.github.com/repos/Financial-Times/next-stream-page/git/commits{/sha}","comments_url":"https://api.github.com/repos/Financial-Times/next-stream-page/comments{/number}","issue_comment_url":"https://api.github.com/repos/Financial-Times/next-stream-page/issues/comments{/number}","contents_url":"https://api.github.com/repos/Financial-Times/next-stream-page/contents/{+path}","compare_url":"https://api.github.com/repos/Financial-Times/next-stream-page/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Financial-Times/next-stream-page/merges","archive_url":"https://api.github.com/repos/Financial-Times/next-stream-page/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Financial-Times/next-stream-page/downloads","issues_url":"https://api.github.com/repos/Financial-Times/next-stream-page/issues{/number}","pulls_url":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls{/number}","milestones_url":"https://api.github.com/repos/Financial-Times/next-stream-page/milestones{/number}","notifications_url":"https://api.github.com/repos/Financial-Times/next-stream-page/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Financial-Times/next-stream-page/labels{/name}","releases_url":"https://api.github.com/repos/Financial-Times/next-stream-page/releases{/id}","deployments_url":"https://api.github.com/repos/Financial-Times/next-stream-page/deployments","created_at":"2014-09-29T13:09:59Z","updated_at":"2016-04-05T10:02:31Z","pushed_at":"2016-06-22T08:45:48Z","git_url":"git://github.com/Financial-Times/next-stream-page.git","ssh_url":"git@github.com:Financial-Times/next-stream-page.git","clone_url":"https://github.com/Financial-Times/next-stream-page.git","svn_url":"https://github.com/Financial-Times/next-stream-page","homepage":"","size":7501,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":20,"forks":2,"open_issues":20,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/1156"},"html":{"href":"https://github.com/Financial-Times/next-stream-page/pull/1156"},"issue":{"href":"https://api.github.com/repos/Financial-Times/next-stream-page/issues/1156"},"comments":{"href":"https://api.github.com/repos/Financial-Times/next-stream-page/issues/1156/comments"},"review_comments":{"href":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/1156/comments"},"review_comment":{"href":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Financial-Times/next-stream-page/pulls/1156/commits"},"statuses":{"href":"https://api.github.com/repos/Financial-Times/next-stream-page/statuses/7127881e22f5268e2515f7b8bf02c5bc4abf965c"}}}}
{"actor":{"display_login":"bjfletcher"}}