{"action":"created","comment":{"url":"https://api.github.com/repos/poetapp/node/pulls/comments/201569622","pull_request_review_id":136095749,"id":201569622,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTU2OTYyMg==","diff_hunk":"@@ -0,0 +1,98 @@\n+import * as FormData from 'form-data'\n+import fetch from 'node-fetch'\n+import * as str from 'string-to-stream'\n+\n+interface IPFSConfiguration {\n+  readonly ipfsUrl: string\n+}\n+\n+interface FetchConfiguration {\n+  readonly timeout: number\n+}\n+\n+enum Type {\n+  File = 'File',\n+  Directory = 'Directory',\n+}\n+\n+interface IPFSObject {\n+  readonly Name?: string\n+  readonly Hash: string\n+  readonly Size?: number\n+  readonly Type?: Type\n+  readonly Links?: ReadonlyArray<IPFSObject>\n+}\n+\n+interface LSResult {\n+  Arguments: {\n+    [key: string]: string\n+  }\n+  Objects: {\n+    [key: string]: IPFSObject\n+  }\n+}\n+\n+type addFileToDirectory = (directoryHash: string, fileName: string, filehash: string) => Promise<IPFSObject>\n+\n+type addText = (text: string, x?: FetchConfiguration) => Promise<IPFSObject>\n+\n+type cat = (s: string, x?: FetchConfiguration) => Promise<string>\n+\n+type createEmptyDirectory = () => Promise<IPFSObject>\n+\n+type getDirectoryFileHashes = (s: string) => Promise<ReadonlyArray<string>>\n+\n+type ls = (s: string) => Promise<LSResult>\n+\n+export class IPFS {\n+  private readonly url: string\n+\n+  constructor(configuration: IPFSConfiguration) {\n+    this.url = configuration.ipfsUrl\n+  }\n+\n+  addFileToDirectory: addFileToDirectory = async (directoryHash, fileName, fileHash) => {\n+    const response = await fetch(\n+      `${this.url}/api/v0/object/patch/add-link?arg=${directoryHash}&arg=${fileName}&arg=${fileHash}`\n+    )\n+    return await response.json()\n+  }\n+\n+  addText: addText = async (text: string, fetchConfiguration) => {\n+    const formData = new FormData() // { maxDataSize: 20971520 }\n+\n+    formData.append('file', str(text), {\n+      knownLength: text.length,\n+      filename: 'file',\n+      contentType: 'plain/text',\n+    })\n+\n+    const response = await fetch(`${this.url}/api/v0/add`, {\n+      ...fetchConfiguration,\n+      method: 'post',\n+      body: formData,\n+    })\n+\n+    return await response.json()\n+  }\n+\n+  cat: cat = async (hash, fetchOptions) => {\n+    const response = await fetch(`${this.url}/api/v0/cat?arg=${hash}`, fetchOptions)\n+    return response.text()","path":"src/Helpers/IPFSClient.ts","position":81,"original_position":81,"commit_id":"8120d972876f41541f5263366b2090a6def7e5c0","original_commit_id":"8120d972876f41541f5263366b2090a6def7e5c0","user":{"login":"kennylavender","id":5175120,"node_id":"MDQ6VXNlcjUxNzUxMjA=","avatar_url":"https://avatars1.githubusercontent.com/u/5175120?v=4","gravatar_id":"","url":"https://api.github.com/users/kennylavender","html_url":"https://github.com/kennylavender","followers_url":"https://api.github.com/users/kennylavender/followers","following_url":"https://api.github.com/users/kennylavender/following{/other_user}","gists_url":"https://api.github.com/users/kennylavender/gists{/gist_id}","starred_url":"https://api.github.com/users/kennylavender/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennylavender/subscriptions","organizations_url":"https://api.github.com/users/kennylavender/orgs","repos_url":"https://api.github.com/users/kennylavender/repos","events_url":"https://api.github.com/users/kennylavender/events{/privacy}","received_events_url":"https://api.github.com/users/kennylavender/received_events","type":"User","site_admin":false},"body":"Cool, so I think we should be able to change it now to `response.json()` without breaking anything I think.","created_at":"2018-07-11T05:38:41Z","updated_at":"2018-07-11T05:38:41Z","html_url":"https://github.com/poetapp/node/pull/215#discussion_r201569622","pull_request_url":"https://api.github.com/repos/poetapp/node/pulls/215","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/poetapp/node/pulls/comments/201569622"},"html":{"href":"https://github.com/poetapp/node/pull/215#discussion_r201569622"},"pull_request":{"href":"https://api.github.com/repos/poetapp/node/pulls/215"}},"in_reply_to_id":201560329},"pull_request":{"url":"https://api.github.com/repos/poetapp/node/pulls/215","id":200581490,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwNTgxNDkw","html_url":"https://github.com/poetapp/node/pull/215","diff_url":"https://github.com/poetapp/node/pull/215.diff","patch_url":"https://github.com/poetapp/node/pull/215.patch","issue_url":"https://api.github.com/repos/poetapp/node/issues/215","number":215,"state":"open","locked":false,"title":"Implement Helpers/IPFSClient.ts","user":{"login":"kennylavender","id":5175120,"node_id":"MDQ6VXNlcjUxNzUxMjA=","avatar_url":"https://avatars1.githubusercontent.com/u/5175120?v=4","gravatar_id":"","url":"https://api.github.com/users/kennylavender","html_url":"https://github.com/kennylavender","followers_url":"https://api.github.com/users/kennylavender/followers","following_url":"https://api.github.com/users/kennylavender/following{/other_user}","gists_url":"https://api.github.com/users/kennylavender/gists{/gist_id}","starred_url":"https://api.github.com/users/kennylavender/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennylavender/subscriptions","organizations_url":"https://api.github.com/users/kennylavender/orgs","repos_url":"https://api.github.com/users/kennylavender/repos","events_url":"https://api.github.com/users/kennylavender/events{/privacy}","received_events_url":"https://api.github.com/users/kennylavender/received_events","type":"User","site_admin":false},"body":"resolves #187 \r\n\r\nSimply implements the Helpers/IPFSClient.ts module, hooking it up and using it in other modules will be done in future pull requests.\r\n\r\n\r\n- no dependency injection\r\n- created as a class for consistency\r\n- implements relevant IPFS methods needed for\r\n  - Storage\r\n  - BatchReader\r\n  - BatchWriter\r\n- methods should be generalized, not specific to certain modules anymore.\r\n\r\n### PR Review Checklist\r\n\r\n* [ ] **Have you tested the changes?**\r\n* [ ] **Is QE review required? If so, has this been reviewed by QE?** (For all new features, review by QE is required. Minor changes which already have passing functional tests may not need a new QE review -- when in doubt, loop in a QE reviewer).\r\n* [ ] **Are there code changes that require new unit tests? If so, are those tests included?** (A separate PR for tests is not appropriate).\r\n* [ ] **Are documentation updates required? If so, does this PR include it?** (Separate documentation PR is generally not appropriate).\r\n* [ ] **Are the added/edited files named appropriately and located correctly in the project directory structure?**\r\n\r\n","created_at":"2018-07-11T04:06:12Z","updated_at":"2018-07-11T05:38:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a988ad1e458bd0c8ee302e43fa69c461466017a3","assignee":null,"assignees":[],"requested_reviewers":[{"login":"lautarodragan","id":2279687,"node_id":"MDQ6VXNlcjIyNzk2ODc=","avatar_url":"https://avatars2.githubusercontent.com/u/2279687?v=4","gravatar_id":"","url":"https://api.github.com/users/lautarodragan","html_url":"https://github.com/lautarodragan","followers_url":"https://api.github.com/users/lautarodragan/followers","following_url":"https://api.github.com/users/lautarodragan/following{/other_user}","gists_url":"https://api.github.com/users/lautarodragan/gists{/gist_id}","starred_url":"https://api.github.com/users/lautarodragan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lautarodragan/subscriptions","organizations_url":"https://api.github.com/users/lautarodragan/orgs","repos_url":"https://api.github.com/users/lautarodragan/repos","events_url":"https://api.github.com/users/lautarodragan/events{/privacy}","received_events_url":"https://api.github.com/users/lautarodragan/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/poetapp/node/pulls/215/commits","review_comments_url":"https://api.github.com/repos/poetapp/node/pulls/215/comments","review_comment_url":"https://api.github.com/repos/poetapp/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/poetapp/node/issues/215/comments","statuses_url":"https://api.github.com/repos/poetapp/node/statuses/8120d972876f41541f5263366b2090a6def7e5c0","head":{"label":"poetapp:ipfs-client-#187","ref":"ipfs-client-#187","sha":"8120d972876f41541f5263366b2090a6def7e5c0","user":{"login":"poetapp","id":24881331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODgxMzMx","avatar_url":"https://avatars0.githubusercontent.com/u/24881331?v=4","gravatar_id":"","url":"https://api.github.com/users/poetapp","html_url":"https://github.com/poetapp","followers_url":"https://api.github.com/users/poetapp/followers","following_url":"https://api.github.com/users/poetapp/following{/other_user}","gists_url":"https://api.github.com/users/poetapp/gists{/gist_id}","starred_url":"https://api.github.com/users/poetapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poetapp/subscriptions","organizations_url":"https://api.github.com/users/poetapp/orgs","repos_url":"https://api.github.com/users/poetapp/repos","events_url":"https://api.github.com/users/poetapp/events{/privacy}","received_events_url":"https://api.github.com/users/poetapp/received_events","type":"Organization","site_admin":false},"repo":{"id":108142666,"node_id":"MDEwOlJlcG9zaXRvcnkxMDgxNDI2NjY=","name":"node","full_name":"poetapp/node","owner":{"login":"poetapp","id":24881331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODgxMzMx","avatar_url":"https://avatars0.githubusercontent.com/u/24881331?v=4","gravatar_id":"","url":"https://api.github.com/users/poetapp","html_url":"https://github.com/poetapp","followers_url":"https://api.github.com/users/poetapp/followers","following_url":"https://api.github.com/users/poetapp/following{/other_user}","gists_url":"https://api.github.com/users/poetapp/gists{/gist_id}","starred_url":"https://api.github.com/users/poetapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poetapp/subscriptions","organizations_url":"https://api.github.com/users/poetapp/orgs","repos_url":"https://api.github.com/users/poetapp/repos","events_url":"https://api.github.com/users/poetapp/events{/privacy}","received_events_url":"https://api.github.com/users/poetapp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/poetapp/node","description":"Po.et is a decentralized platform for managing creative assets","fork":false,"url":"https://api.github.com/repos/poetapp/node","forks_url":"https://api.github.com/repos/poetapp/node/forks","keys_url":"https://api.github.com/repos/poetapp/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/poetapp/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/poetapp/node/teams","hooks_url":"https://api.github.com/repos/poetapp/node/hooks","issue_events_url":"https://api.github.com/repos/poetapp/node/issues/events{/number}","events_url":"https://api.github.com/repos/poetapp/node/events","assignees_url":"https://api.github.com/repos/poetapp/node/assignees{/user}","branches_url":"https://api.github.com/repos/poetapp/node/branches{/branch}","tags_url":"https://api.github.com/repos/poetapp/node/tags","blobs_url":"https://api.github.com/repos/poetapp/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/poetapp/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/poetapp/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/poetapp/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/poetapp/node/statuses/{sha}","languages_url":"https://api.github.com/repos/poetapp/node/languages","stargazers_url":"https://api.github.com/repos/poetapp/node/stargazers","contributors_url":"https://api.github.com/repos/poetapp/node/contributors","subscribers_url":"https://api.github.com/repos/poetapp/node/subscribers","subscription_url":"https://api.github.com/repos/poetapp/node/subscription","commits_url":"https://api.github.com/repos/poetapp/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/poetapp/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/poetapp/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/poetapp/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/poetapp/node/contents/{+path}","compare_url":"https://api.github.com/repos/poetapp/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/poetapp/node/merges","archive_url":"https://api.github.com/repos/poetapp/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/poetapp/node/downloads","issues_url":"https://api.github.com/repos/poetapp/node/issues{/number}","pulls_url":"https://api.github.com/repos/poetapp/node/pulls{/number}","milestones_url":"https://api.github.com/repos/poetapp/node/milestones{/number}","notifications_url":"https://api.github.com/repos/poetapp/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/poetapp/node/labels{/name}","releases_url":"https://api.github.com/repos/poetapp/node/releases{/id}","deployments_url":"https://api.github.com/repos/poetapp/node/deployments","created_at":"2017-10-24T14:58:14Z","updated_at":"2018-07-10T19:51:14Z","pushed_at":"2018-07-11T04:10:13Z","git_url":"git://github.com/poetapp/node.git","ssh_url":"git@github.com:poetapp/node.git","clone_url":"https://github.com/poetapp/node.git","svn_url":"https://github.com/poetapp/node","homepage":"https://po.et","size":623,"stargazers_count":129,"watchers_count":129,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":47,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":19,"open_issues":47,"watchers":129,"default_branch":"master"}},"base":{"label":"poetapp:master","ref":"master","sha":"ed799094f69667edd32015a2e14a9e971707e4f5","user":{"login":"poetapp","id":24881331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODgxMzMx","avatar_url":"https://avatars0.githubusercontent.com/u/24881331?v=4","gravatar_id":"","url":"https://api.github.com/users/poetapp","html_url":"https://github.com/poetapp","followers_url":"https://api.github.com/users/poetapp/followers","following_url":"https://api.github.com/users/poetapp/following{/other_user}","gists_url":"https://api.github.com/users/poetapp/gists{/gist_id}","starred_url":"https://api.github.com/users/poetapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poetapp/subscriptions","organizations_url":"https://api.github.com/users/poetapp/orgs","repos_url":"https://api.github.com/users/poetapp/repos","events_url":"https://api.github.com/users/poetapp/events{/privacy}","received_events_url":"https://api.github.com/users/poetapp/received_events","type":"Organization","site_admin":false},"repo":{"id":108142666,"node_id":"MDEwOlJlcG9zaXRvcnkxMDgxNDI2NjY=","name":"node","full_name":"poetapp/node","owner":{"login":"poetapp","id":24881331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODgxMzMx","avatar_url":"https://avatars0.githubusercontent.com/u/24881331?v=4","gravatar_id":"","url":"https://api.github.com/users/poetapp","html_url":"https://github.com/poetapp","followers_url":"https://api.github.com/users/poetapp/followers","following_url":"https://api.github.com/users/poetapp/following{/other_user}","gists_url":"https://api.github.com/users/poetapp/gists{/gist_id}","starred_url":"https://api.github.com/users/poetapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poetapp/subscriptions","organizations_url":"https://api.github.com/users/poetapp/orgs","repos_url":"https://api.github.com/users/poetapp/repos","events_url":"https://api.github.com/users/poetapp/events{/privacy}","received_events_url":"https://api.github.com/users/poetapp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/poetapp/node","description":"Po.et is a decentralized platform for managing creative assets","fork":false,"url":"https://api.github.com/repos/poetapp/node","forks_url":"https://api.github.com/repos/poetapp/node/forks","keys_url":"https://api.github.com/repos/poetapp/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/poetapp/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/poetapp/node/teams","hooks_url":"https://api.github.com/repos/poetapp/node/hooks","issue_events_url":"https://api.github.com/repos/poetapp/node/issues/events{/number}","events_url":"https://api.github.com/repos/poetapp/node/events","assignees_url":"https://api.github.com/repos/poetapp/node/assignees{/user}","branches_url":"https://api.github.com/repos/poetapp/node/branches{/branch}","tags_url":"https://api.github.com/repos/poetapp/node/tags","blobs_url":"https://api.github.com/repos/poetapp/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/poetapp/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/poetapp/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/poetapp/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/poetapp/node/statuses/{sha}","languages_url":"https://api.github.com/repos/poetapp/node/languages","stargazers_url":"https://api.github.com/repos/poetapp/node/stargazers","contributors_url":"https://api.github.com/repos/poetapp/node/contributors","subscribers_url":"https://api.github.com/repos/poetapp/node/subscribers","subscription_url":"https://api.github.com/repos/poetapp/node/subscription","commits_url":"https://api.github.com/repos/poetapp/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/poetapp/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/poetapp/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/poetapp/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/poetapp/node/contents/{+path}","compare_url":"https://api.github.com/repos/poetapp/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/poetapp/node/merges","archive_url":"https://api.github.com/repos/poetapp/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/poetapp/node/downloads","issues_url":"https://api.github.com/repos/poetapp/node/issues{/number}","pulls_url":"https://api.github.com/repos/poetapp/node/pulls{/number}","milestones_url":"https://api.github.com/repos/poetapp/node/milestones{/number}","notifications_url":"https://api.github.com/repos/poetapp/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/poetapp/node/labels{/name}","releases_url":"https://api.github.com/repos/poetapp/node/releases{/id}","deployments_url":"https://api.github.com/repos/poetapp/node/deployments","created_at":"2017-10-24T14:58:14Z","updated_at":"2018-07-10T19:51:14Z","pushed_at":"2018-07-11T04:10:13Z","git_url":"git://github.com/poetapp/node.git","ssh_url":"git@github.com:poetapp/node.git","clone_url":"https://github.com/poetapp/node.git","svn_url":"https://github.com/poetapp/node","homepage":"https://po.et","size":623,"stargazers_count":129,"watchers_count":129,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"archived":false,"open_issues_count":47,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":19,"open_issues":47,"watchers":129,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/poetapp/node/pulls/215"},"html":{"href":"https://github.com/poetapp/node/pull/215"},"issue":{"href":"https://api.github.com/repos/poetapp/node/issues/215"},"comments":{"href":"https://api.github.com/repos/poetapp/node/issues/215/comments"},"review_comments":{"href":"https://api.github.com/repos/poetapp/node/pulls/215/comments"},"review_comment":{"href":"https://api.github.com/repos/poetapp/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/poetapp/node/pulls/215/commits"},"statuses":{"href":"https://api.github.com/repos/poetapp/node/statuses/8120d972876f41541f5263366b2090a6def7e5c0"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"kennylavender"}}