Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 7bac678

Browse files
authoredSep 28, 2021
chore: add ipfs http response package
This PR adds the content of https://github.com/ipfs/js-ipfs-http-response to this monorepo to smooth its maintenance burden.
2 parents 7cb9861 + f8cc058 commit 7bac678

29 files changed

+28142
-0
lines changed
 

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ This project is broken into several modules, their purposes are:
117117
* [`/packages/ipfs-grpc-server`](./packages/ipfs-grpc-server) A gRPC-over-websockets server for js-IPFS
118118
* [`/packages/ipfs-http-client`](./packages/ipfs-http-client) A client for the RPC-over-HTTP API presented by both js-ipfs and go-ipfs
119119
* [`/packages/ipfs-http-gateway`](./packages/ipfs-http-gateway) JS implementation of the [IPFS HTTP Gateway](https://docs.ipfs.io/concepts/ipfs-gateway/)
120+
* [`/packages/ipfs-http-response`](./packages/ipfs-http-response) Creates a HTTP response for a given IPFS Path
120121
* [`/packages/ipfs-http-server`](./packages/ipfs-http-server) JS implementation of the [IPFS HTTP API](https://docs.ipfs.io/reference/http/api/)
121122
* [`/packages/ipfs-message-port-client`](./packages/ipfs-http-client) A client for the RPC-over-HTTP API presented by both js-ipfs and go-ipfs
122123
* [`/packages/ipfs-message-port-client`](./packages/ipfs-message-port-client) A client for the RPC-over-message-port API presented by js-ipfs running in a shared worker
+203
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
## [1.0.1](https://github.com/ipfs/js-ipfs-http-response/compare/v1.0.0...v1.0.1) (2021-09-08)
2+
3+
4+
5+
# [1.0.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.7.0...v1.0.0) (2021-09-07)
6+
7+
8+
### Bug Fixes
9+
10+
* update module ([#104](https://github.com/ipfs/js-ipfs-http-response/issues/104)) ([319e2b4](https://github.com/ipfs/js-ipfs-http-response/commit/319e2b416bb6283e0f0e67c7dc9f609851e16909))
11+
12+
13+
14+
# [0.7.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.6.4...v0.7.0) (2021-07-12)
15+
16+
17+
### chore
18+
19+
* update to new multiformats ([#98](https://github.com/ipfs/js-ipfs-http-response/issues/98)) ([1641cef](https://github.com/ipfs/js-ipfs-http-response/commit/1641cefaa2cc965ddd7fdaa2d9be8dd7b0150665))
20+
21+
22+
### BREAKING CHANGES
23+
24+
* pulls in new multiformats modules
25+
26+
27+
28+
## [0.6.4](https://github.com/ipfs/js-ipfs-http-response/compare/v0.6.3...v0.6.4) (2021-04-16)
29+
30+
31+
32+
## [0.6.3](https://github.com/ipfs/js-ipfs-http-response/compare/v0.6.2...v0.6.3) (2021-04-12)
33+
34+
35+
36+
## [0.6.2](https://github.com/ipfs/js-ipfs-http-response/compare/v0.6.1...v0.6.2) (2021-03-17)
37+
38+
39+
### Bug Fixes
40+
41+
* add node dev deps ([#81](https://github.com/ipfs/js-ipfs-http-response/issues/81)) ([9fcc821](https://github.com/ipfs/js-ipfs-http-response/commit/9fcc8215d511e6e9071f0fb9fd927d9005a72670))
42+
43+
44+
45+
## [0.6.1](https://github.com/ipfs/js-ipfs-http-response/compare/v0.6.0...v0.6.1) (2020-12-22)
46+
47+
48+
49+
<a name="0.6.0"></a>
50+
# [0.6.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.5.1...v0.6.0) (2020-08-14)
51+
52+
53+
### Bug Fixes
54+
55+
* replace node buffers with uint8arrays ([#55](https://github.com/ipfs/js-ipfs-http-response/issues/55)) ([710a96d](https://github.com/ipfs/js-ipfs-http-response/commit/710a96d))
56+
* webpack build ([#56](https://github.com/ipfs/js-ipfs-http-response/issues/56)) ([0c61a36](https://github.com/ipfs/js-ipfs-http-response/commit/0c61a36))
57+
58+
59+
### BREAKING CHANGES
60+
61+
* - All deps of this module use Uint8Arrays instead of node Buffers
62+
63+
* chore: remove browser build steps
64+
65+
66+
67+
<a name="0.5.1"></a>
68+
## [0.5.1](https://github.com/ipfs/js-ipfs-http-response/compare/v0.5.0...v0.5.1) (2020-06-30)
69+
70+
71+
### Bug Fixes
72+
73+
* **ci:** add empty commit to fix lint checks on master ([1db03b0](https://github.com/ipfs/js-ipfs-http-response/commit/1db03b0))
74+
75+
76+
77+
<a name="0.5.0"></a>
78+
# [0.5.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.4.0...v0.5.0) (2020-01-07)
79+
80+
81+
### Code Refactoring
82+
83+
* use new IPFS async/await APIs ([#30](https://github.com/ipfs/js-ipfs-http-response/issues/30)) ([68f1204](https://github.com/ipfs/js-ipfs-http-response/commit/68f1204))
84+
85+
86+
### BREAKING CHANGES
87+
88+
* Switch to using async/await and async iterators.
89+
90+
91+
92+
<a name="0.4.0"></a>
93+
# [0.4.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.3.1...v0.4.0) (2019-10-14)
94+
95+
96+
### Chores
97+
98+
* convert to async await syntax ([#28](https://github.com/ipfs/js-ipfs-http-response/issues/28)) ([a22900a](https://github.com/ipfs/js-ipfs-http-response/commit/a22900a))
99+
100+
101+
### BREAKING CHANGES
102+
103+
* All places in the API that used callbacks are now replaced with async/await
104+
105+
Co-authored-by: PedroMiguelSS <pedro.santos@moxy.studio>
106+
107+
108+
109+
<a name="0.3.1"></a>
110+
## [0.3.1](https://github.com/ipfs/js-ipfs-http-response/compare/v0.2.2...v0.3.1) (2019-06-06)
111+
112+
113+
### Bug Fixes
114+
115+
* create .npmignore to include dist on npm ([#16](https://github.com/ipfs/js-ipfs-http-response/issues/16)) ([7746dab](https://github.com/ipfs/js-ipfs-http-response/commit/7746dab))
116+
117+
118+
### Chores
119+
120+
* update ipld formats ([#25](https://github.com/ipfs/js-ipfs-http-response/issues/25)) ([529613a](https://github.com/ipfs/js-ipfs-http-response/commit/529613a))
121+
122+
123+
### Features
124+
125+
* load files/dirs from hamt shards ([#19](https://github.com/ipfs/js-ipfs-http-response/issues/19)) ([25edfbc](https://github.com/ipfs/js-ipfs-http-response/commit/25edfbc))
126+
127+
128+
### BREAKING CHANGES
129+
130+
* v1 CIDs created by this module now default to base32 encoding when stringified
131+
132+
Not a direct dependency of this module but ipld-dag-pb changed the
133+
case of some property names that are used by this module.
134+
135+
License: MIT
136+
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
137+
138+
139+
140+
<a name="0.3.0"></a>
141+
## [0.3.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.2.2...v0.3.0) (2019-05-21)
142+
143+
BREAKING CHANGE: v1 CIDs created by this module now default to base32 encoding when stringified
144+
145+
Not a direct dependency of this module but ipld-dag-pb changed the
146+
case of some property names that are used by this module.
147+
148+
<a name="0.2.2"></a>
149+
## [0.2.2](https://github.com/ipfs/js-ipfs-http-response/compare/v0.2.1...v0.2.2) (2019-01-19)
150+
151+
152+
153+
<a name="0.2.1"></a>
154+
## [0.2.1](https://github.com/ipfs/js-ipfs-http-response/compare/v0.1.4...v0.2.1) (2018-11-09)
155+
156+
157+
### Bug Fixes
158+
159+
* use .cid property before falling back to .multihash ([#12](https://github.com/ipfs/js-ipfs-http-response/issues/12)) ([1c1a478](https://github.com/ipfs/js-ipfs-http-response/commit/1c1a478))
160+
161+
162+
163+
<a name="0.2.0"></a>
164+
## [0.2.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.1.4...v0.2.0) (2018-09-28)
165+
166+
167+
168+
<a name="0.1.4"></a>
169+
## [0.1.4](https://github.com/ipfs/js-ipfs-http-response/compare/v0.1.3...v0.1.4) (2018-08-02)
170+
171+
172+
### Bug Fixes
173+
174+
* fix content-type by doing a fall-back using extensions ([#5](https://github.com/ipfs/js-ipfs-http-response/issues/5)) ([19acbae](https://github.com/ipfs/js-ipfs-http-response/commit/19acbae))
175+
176+
177+
178+
<a name="0.1.3"></a>
179+
## [0.1.3](https://github.com/ipfs/js-ipfs-http-response/compare/v0.1.2...v0.1.3) (2018-07-28)
180+
181+
182+
### Bug Fixes
183+
184+
* firefox using readable stream ([#3](https://github.com/ipfs/js-ipfs-http-response/issues/3)) ([0bff82d](https://github.com/ipfs/js-ipfs-http-response/commit/0bff82d))
185+
186+
187+
188+
<a name="0.1.2"></a>
189+
## 0.1.2 (2018-06-01)
190+
191+
192+
### Bug Fixes
193+
194+
* update package name ([91b99b3](https://github.com/ipfs/js-ipfs-http-response/commit/91b99b3))
195+
196+
197+
### Features
198+
199+
* export resolver ([d9e56b8](https://github.com/ipfs/js-ipfs-http-response/commit/d9e56b8))
200+
* initial implementation ([d9d0c08](https://github.com/ipfs/js-ipfs-http-response/commit/d9d0c08))
201+
202+
203+

‎packages/ipfs-http-response/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 IPFS
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎packages/ipfs-http-response/README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# js-ipfs-http-response
2+
3+
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
4+
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
5+
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
6+
[![standard-readme](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
7+
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
8+
9+
> Creates an HTTP response from an IPFS Hash
10+
11+
## Lead Maintainer
12+
13+
[Vasco Santos](https://github.com/vasco-santos).
14+
15+
### Installation
16+
17+
> npm install ipfs-http-response
18+
19+
## Usage
20+
21+
22+
### Creating HTTP Response
23+
24+
This project creates a HTTP response for an IPFS Path. This response can be a file, a HTML with directory listing or the entry point of a web page.
25+
26+
```js
27+
import { getResponse } from 'ipfs-http-response'
28+
29+
const result = await getResponse(ipfsNode, ipfsPath)
30+
console.log(result)
31+
```
32+
33+
### Using protocol-agnostic resolver
34+
35+
This module also exports the used ipfs `resolver`, which should be used when the response needs to be customized or non-HTTP transport is used:
36+
37+
```js
38+
import { resolver } from 'ipfs-http-response'
39+
40+
const result = await resolver.cid(ipfsNode, ipfsPath)
41+
console.log(result)
42+
```
43+
44+
If `ipfsPath` points at a directory, `resolver.cid` will throw Error `This dag node is a directory` with a `cid` attribute that can be passed to `resolver.directory`:
45+
46+
47+
```js
48+
import { resolver } from 'ipfs-http-response'
49+
50+
const result = await resolver.directory(ipfsNode, ipfsPath, cid)
51+
console.log(result)
52+
```
53+
54+
`result` will be either a `string` with HTML directory listing or an array with CIDs of `index` pages present in inspected directory.
55+
56+
![ipfs-http-response usage](docs/ipfs-http-response.png "ipfs-http-response usage")
Loading
+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"name": "ipfs-http-response",
3+
"version": "1.0.1",
4+
"description": "Creates an HTTP response from an IPFS Hash",
5+
"leadMaintainer": "Vasco Santos <vasco.santos@moxy.studio>",
6+
"main": "src/index.js",
7+
"types": "types/src/index.d.ts",
8+
"typesVersions": {
9+
"*": {
10+
"*": [
11+
"types/*",
12+
"types/src/*"
13+
],
14+
"types/*": [
15+
"types/*",
16+
"types/src/*"
17+
]
18+
}
19+
},
20+
"type": "module",
21+
"eslintConfig": {
22+
"extends": "ipfs",
23+
"parserOptions": {
24+
"sourceType": "module"
25+
}
26+
},
27+
"exports": {
28+
".": {
29+
"import": "./src/index.js"
30+
}
31+
},
32+
"publishConfig": {
33+
"directory": "dist"
34+
},
35+
"scripts": {
36+
"lint": "aegir ts -p check && aegir lint",
37+
"build": "aegir build",
38+
"release": "aegir release --target node",
39+
"release-minor": "aegir release --type minor --target node",
40+
"release-major": "aegir release --type major --target node",
41+
"pretest": "aegir build --esm-tests",
42+
"test": "aegir test -t node",
43+
"test:node": "aegir test -t node"
44+
},
45+
"browser": {
46+
"file-type": "file-type/browser",
47+
"fs": false
48+
},
49+
"repository": {
50+
"type": "git",
51+
"url": "git+https://github.com/ipfs/js-ipfs-http-response.git"
52+
},
53+
"keywords": [
54+
"ipfs",
55+
"http",
56+
"response"
57+
],
58+
"author": "Vasco Santos <vasco.santos@moxy.studio>",
59+
"license": "MIT",
60+
"bugs": {
61+
"url": "https://github.com/ipfs/js-ipfs-http-response/issues"
62+
},
63+
"homepage": "https://github.com/ipfs/js-ipfs-http-response#readme",
64+
"dependencies": {
65+
"debug": "^4.3.1",
66+
"ejs": "^3.1.6",
67+
"file-type": "^16.0.0",
68+
"filesize": "^8.0.0",
69+
"it-buffer": "^0.1.1",
70+
"it-concat": "^2.0.0",
71+
"it-reader": "^3.0.0",
72+
"it-to-stream": "^1.0.0",
73+
"mime-types": "^2.1.30",
74+
"multiformats": "^9.2.0",
75+
"p-try-each": "^1.0.1"
76+
},
77+
"devDependencies": {
78+
"@types/ejs": "^3.1.0",
79+
"aegir": "^35.0.3",
80+
"get-stream": "^6.0.0",
81+
"ipfs-core": "^0.10.5",
82+
"ipfsd-ctl": "^10.0.1",
83+
"it-all": "^1.0.5",
84+
"path": "^0.12.7",
85+
"uint8arrays": "^3.0.0",
86+
"util": "^0.12.3"
87+
},
88+
"contributors": [
89+
"Vasco Santos <vasco.santos@moxy.studio>",
90+
"Alex Potsides <alex@achingbrain.net>",
91+
"Hector Sanjuan <code@hector.link>",
92+
"Marcin Rataj <lidel@lidel.org>",
93+
"André Cruz <andremiguelcruz@msn.com>",
94+
"Irakli Gozalishvili <rfobic@gmail.com>",
95+
"Alan Shaw <alan.shaw@protocol.ai>",
96+
"Pedro Santos <pedro.santos@moxy.studio>"
97+
]
98+
}

0 commit comments

Comments
 (0)
This repository has been archived.