{"action":"created","comment":{"url":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/comments/166052410","pull_request_review_id":94078652,"id":166052410,"diff_hunk":"@@ -43,60 +42,62 @@ function isHttp2Request(req: RawRequest): req is http2.Http2ServerRequest {\n   return !!(req as http2.Http2ServerRequest).stream;\n }\n \n+function isHttp2Response(res: RawResponse): res is http2.Http2ServerResponse {\n+  return !!(res as http2.Http2ServerResponse).stream;\n+}\n+\n const CACHE_COOKIE_KEY = '__ap_cache__';\n \n-function staticServeFn(\n+// TODO use a Symbol if ts behaves\n+interface StorePath extends http2.Http2Stream {\n+  __req_path?: string;\n+}\n+\n+async function staticServeFn(\n     app: fastify.FastifyInstance<HttpServer, RawRequest, RawResponse>,\n-    opts: AutoPushOptions, done?: (err?: Error) => void): void {\n+    opts: AutoPushOptions): Promise<void> {\n   const root = opts.root;\n-  let prefix = opts.prefix;\n+  const prefix = opts.prefix || '';\n   const ap = new autoPush.AutoPush(root, opts.cacheConfig);\n \n-  if (prefix === undefined) prefix = '/';\n-  if (prefix[0] !== '/') prefix = '/' + prefix;\n-  if (prefix[prefix.length - 1] !== '/') prefix += '/';\n-  app.get(prefix + '*', async (req: Request, res: Response) => {\n-    const reqPath: string = prefix + (req.params['*'] || '');\n-    if (isHttp2Request(req.req)) {\n-      const reqStream = req.req.stream;\n-      const cookies = cookie.parse(req.req.headers['cookie'] as string || '');\n+  app.register(require('fastify-static'), opts);","path":"ts/src/index.ts","position":41,"original_position":41,"commit_id":"4742e56edcabd79392b2a6da899139c729ea9ba9","original_commit_id":"4742e56edcabd79392b2a6da899139c729ea9ba9","user":{"login":"jinwoo","id":1570213,"avatar_url":"https://avatars2.githubusercontent.com/u/1570213?v=4","gravatar_id":"","url":"https://api.github.com/users/jinwoo","html_url":"https://github.com/jinwoo","followers_url":"https://api.github.com/users/jinwoo/followers","following_url":"https://api.github.com/users/jinwoo/following{/other_user}","gists_url":"https://api.github.com/users/jinwoo/gists{/gist_id}","starred_url":"https://api.github.com/users/jinwoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jinwoo/subscriptions","organizations_url":"https://api.github.com/users/jinwoo/orgs","repos_url":"https://api.github.com/users/jinwoo/repos","events_url":"https://api.github.com/users/jinwoo/events{/privacy}","received_events_url":"https://api.github.com/users/jinwoo/received_events","type":"User","site_admin":false},"body":"Will it be possible to move this `require('fastify-static')` to the top and use the `import` syntax?","created_at":"2018-02-05T17:46:52Z","updated_at":"2018-02-05T17:54:05Z","html_url":"https://github.com/google/node-fastify-auto-push/pull/6#discussion_r166052410","pull_request_url":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/6","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/comments/166052410"},"html":{"href":"https://github.com/google/node-fastify-auto-push/pull/6#discussion_r166052410"},"pull_request":{"href":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/6","id":166568100,"html_url":"https://github.com/google/node-fastify-auto-push/pull/6","diff_url":"https://github.com/google/node-fastify-auto-push/pull/6.diff","patch_url":"https://github.com/google/node-fastify-auto-push/pull/6.patch","issue_url":"https://api.github.com/repos/google/node-fastify-auto-push/issues/6","number":6,"state":"open","locked":false,"title":"Use fastify-static and hooks instead","user":{"login":"mcollina","id":52195,"avatar_url":"https://avatars0.githubusercontent.com/u/52195?v=4","gravatar_id":"","url":"https://api.github.com/users/mcollina","html_url":"https://github.com/mcollina","followers_url":"https://api.github.com/users/mcollina/followers","following_url":"https://api.github.com/users/mcollina/following{/other_user}","gists_url":"https://api.github.com/users/mcollina/gists{/gist_id}","starred_url":"https://api.github.com/users/mcollina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcollina/subscriptions","organizations_url":"https://api.github.com/users/mcollina/orgs","repos_url":"https://api.github.com/users/mcollina/repos","events_url":"https://api.github.com/users/mcollina/events{/privacy}","received_events_url":"https://api.github.com/users/mcollina/received_events","type":"User","site_admin":false},"body":"This PR moves the plugin to use the latest version of fastify (0.42.0) and fastify-static. It now leverage hooks instead of wrapping `send()` directly - it was not possible before of 0.42.0. ","created_at":"2018-02-01T15:26:38Z","updated_at":"2018-02-05T17:54:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"68575b44b80c62d7e9e1d1080faf5a72ddaaadbb","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/6/commits","review_comments_url":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/6/comments","review_comment_url":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/node-fastify-auto-push/issues/6/comments","statuses_url":"https://api.github.com/repos/google/node-fastify-auto-push/statuses/4742e56edcabd79392b2a6da899139c729ea9ba9","head":{"label":"mcollina:my-updates","ref":"my-updates","sha":"4742e56edcabd79392b2a6da899139c729ea9ba9","user":{"login":"mcollina","id":52195,"avatar_url":"https://avatars0.githubusercontent.com/u/52195?v=4","gravatar_id":"","url":"https://api.github.com/users/mcollina","html_url":"https://github.com/mcollina","followers_url":"https://api.github.com/users/mcollina/followers","following_url":"https://api.github.com/users/mcollina/following{/other_user}","gists_url":"https://api.github.com/users/mcollina/gists{/gist_id}","starred_url":"https://api.github.com/users/mcollina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcollina/subscriptions","organizations_url":"https://api.github.com/users/mcollina/orgs","repos_url":"https://api.github.com/users/mcollina/repos","events_url":"https://api.github.com/users/mcollina/events{/privacy}","received_events_url":"https://api.github.com/users/mcollina/received_events","type":"User","site_admin":false},"repo":{"id":117812952,"name":"node-fastify-auto-push","full_name":"mcollina/node-fastify-auto-push","owner":{"login":"mcollina","id":52195,"avatar_url":"https://avatars0.githubusercontent.com/u/52195?v=4","gravatar_id":"","url":"https://api.github.com/users/mcollina","html_url":"https://github.com/mcollina","followers_url":"https://api.github.com/users/mcollina/followers","following_url":"https://api.github.com/users/mcollina/following{/other_user}","gists_url":"https://api.github.com/users/mcollina/gists{/gist_id}","starred_url":"https://api.github.com/users/mcollina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcollina/subscriptions","organizations_url":"https://api.github.com/users/mcollina/orgs","repos_url":"https://api.github.com/users/mcollina/repos","events_url":"https://api.github.com/users/mcollina/events{/privacy}","received_events_url":"https://api.github.com/users/mcollina/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mcollina/node-fastify-auto-push","description":null,"fork":true,"url":"https://api.github.com/repos/mcollina/node-fastify-auto-push","forks_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/forks","keys_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/teams","hooks_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/hooks","issue_events_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/issues/events{/number}","events_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/events","assignees_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/assignees{/user}","branches_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/branches{/branch}","tags_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/tags","blobs_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/git/refs{/sha}","trees_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/statuses/{sha}","languages_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/languages","stargazers_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/stargazers","contributors_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/contributors","subscribers_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/subscribers","subscription_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/subscription","commits_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/commits{/sha}","git_commits_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/git/commits{/sha}","comments_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/comments{/number}","issue_comment_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/issues/comments{/number}","contents_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/contents/{+path}","compare_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/merges","archive_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/downloads","issues_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/issues{/number}","pulls_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/pulls{/number}","milestones_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/milestones{/number}","notifications_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/labels{/name}","releases_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/releases{/id}","deployments_url":"https://api.github.com/repos/mcollina/node-fastify-auto-push/deployments","created_at":"2018-01-17T09:16:35Z","updated_at":"2018-01-17T09:16:36Z","pushed_at":"2018-02-01T15:50:34Z","git_url":"git://github.com/mcollina/node-fastify-auto-push.git","ssh_url":"git@github.com:mcollina/node-fastify-auto-push.git","clone_url":"https://github.com/mcollina/node-fastify-auto-push.git","svn_url":"https://github.com/mcollina/node-fastify-auto-push","homepage":null,"size":579,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"93b11c88d182ed2b3de408ddd2fc2e6efeaaac01","user":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":117717019,"name":"node-fastify-auto-push","full_name":"google/node-fastify-auto-push","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/node-fastify-auto-push","description":"Fastify plugin for HTTP/2 automatic server push","fork":false,"url":"https://api.github.com/repos/google/node-fastify-auto-push","forks_url":"https://api.github.com/repos/google/node-fastify-auto-push/forks","keys_url":"https://api.github.com/repos/google/node-fastify-auto-push/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/node-fastify-auto-push/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/node-fastify-auto-push/teams","hooks_url":"https://api.github.com/repos/google/node-fastify-auto-push/hooks","issue_events_url":"https://api.github.com/repos/google/node-fastify-auto-push/issues/events{/number}","events_url":"https://api.github.com/repos/google/node-fastify-auto-push/events","assignees_url":"https://api.github.com/repos/google/node-fastify-auto-push/assignees{/user}","branches_url":"https://api.github.com/repos/google/node-fastify-auto-push/branches{/branch}","tags_url":"https://api.github.com/repos/google/node-fastify-auto-push/tags","blobs_url":"https://api.github.com/repos/google/node-fastify-auto-push/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/node-fastify-auto-push/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/node-fastify-auto-push/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/node-fastify-auto-push/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/node-fastify-auto-push/statuses/{sha}","languages_url":"https://api.github.com/repos/google/node-fastify-auto-push/languages","stargazers_url":"https://api.github.com/repos/google/node-fastify-auto-push/stargazers","contributors_url":"https://api.github.com/repos/google/node-fastify-auto-push/contributors","subscribers_url":"https://api.github.com/repos/google/node-fastify-auto-push/subscribers","subscription_url":"https://api.github.com/repos/google/node-fastify-auto-push/subscription","commits_url":"https://api.github.com/repos/google/node-fastify-auto-push/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/node-fastify-auto-push/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/node-fastify-auto-push/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/node-fastify-auto-push/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/node-fastify-auto-push/contents/{+path}","compare_url":"https://api.github.com/repos/google/node-fastify-auto-push/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/node-fastify-auto-push/merges","archive_url":"https://api.github.com/repos/google/node-fastify-auto-push/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/node-fastify-auto-push/downloads","issues_url":"https://api.github.com/repos/google/node-fastify-auto-push/issues{/number}","pulls_url":"https://api.github.com/repos/google/node-fastify-auto-push/pulls{/number}","milestones_url":"https://api.github.com/repos/google/node-fastify-auto-push/milestones{/number}","notifications_url":"https://api.github.com/repos/google/node-fastify-auto-push/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/node-fastify-auto-push/labels{/name}","releases_url":"https://api.github.com/repos/google/node-fastify-auto-push/releases{/id}","deployments_url":"https://api.github.com/repos/google/node-fastify-auto-push/deployments","created_at":"2018-01-16T17:31:24Z","updated_at":"2018-02-02T11:34:59Z","pushed_at":"2018-02-01T15:50:35Z","git_url":"git://github.com/google/node-fastify-auto-push.git","ssh_url":"git@github.com:google/node-fastify-auto-push.git","clone_url":"https://github.com/google/node-fastify-auto-push.git","svn_url":"https://github.com/google/node-fastify-auto-push","homepage":"","size":572,"stargazers_count":19,"watchers_count":19,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":2,"open_issues":2,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/6"},"html":{"href":"https://github.com/google/node-fastify-auto-push/pull/6"},"issue":{"href":"https://api.github.com/repos/google/node-fastify-auto-push/issues/6"},"comments":{"href":"https://api.github.com/repos/google/node-fastify-auto-push/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/node-fastify-auto-push/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/google/node-fastify-auto-push/statuses/4742e56edcabd79392b2a6da899139c729ea9ba9"}},"author_association":"NONE"}}
{"actor":{"display_login":"jinwoo"}}