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

Commit

Permalink
chore: add ipfs http response package
Browse files Browse the repository at this point in the history
This PR adds the content of https://github.com/ipfs/js-ipfs-http-response to this monorepo to smooth its maintenance burden.
  • Loading branch information
achingbrain authored Sep 28, 2021
2 parents 7cb9861 + f8cc058 commit 7bac678
Show file tree
Hide file tree
Showing 29 changed files with 28,142 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ This project is broken into several modules, their purposes are:
* [`/packages/ipfs-grpc-server`](./packages/ipfs-grpc-server) A gRPC-over-websockets server for js-IPFS
* [`/packages/ipfs-http-client`](./packages/ipfs-http-client) A client for the RPC-over-HTTP API presented by both js-ipfs and go-ipfs
* [`/packages/ipfs-http-gateway`](./packages/ipfs-http-gateway) JS implementation of the [IPFS HTTP Gateway](https://docs.ipfs.io/concepts/ipfs-gateway/)
* [`/packages/ipfs-http-response`](./packages/ipfs-http-response) Creates a HTTP response for a given IPFS Path
* [`/packages/ipfs-http-server`](./packages/ipfs-http-server) JS implementation of the [IPFS HTTP API](https://docs.ipfs.io/reference/http/api/)
* [`/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
* [`/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
Expand Down
203 changes: 203 additions & 0 deletions packages/ipfs-http-response/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
## [1.0.1](https://github.com/ipfs/js-ipfs-http-response/compare/v1.0.0...v1.0.1) (2021-09-08)



# [1.0.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.7.0...v1.0.0) (2021-09-07)


### Bug Fixes

* update module ([#104](https://github.com/ipfs/js-ipfs-http-response/issues/104)) ([319e2b4](https://github.com/ipfs/js-ipfs-http-response/commit/319e2b416bb6283e0f0e67c7dc9f609851e16909))



# [0.7.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.6.4...v0.7.0) (2021-07-12)


### chore

* 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))


### BREAKING CHANGES

* pulls in new multiformats modules



## [0.6.4](https://github.com/ipfs/js-ipfs-http-response/compare/v0.6.3...v0.6.4) (2021-04-16)



## [0.6.3](https://github.com/ipfs/js-ipfs-http-response/compare/v0.6.2...v0.6.3) (2021-04-12)



## [0.6.2](https://github.com/ipfs/js-ipfs-http-response/compare/v0.6.1...v0.6.2) (2021-03-17)


### Bug Fixes

* 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))



## [0.6.1](https://github.com/ipfs/js-ipfs-http-response/compare/v0.6.0...v0.6.1) (2020-12-22)



<a name="0.6.0"></a>
# [0.6.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.5.1...v0.6.0) (2020-08-14)


### Bug Fixes

* 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))
* webpack build ([#56](https://github.com/ipfs/js-ipfs-http-response/issues/56)) ([0c61a36](https://github.com/ipfs/js-ipfs-http-response/commit/0c61a36))


### BREAKING CHANGES

* - All deps of this module use Uint8Arrays instead of node Buffers

* chore: remove browser build steps



<a name="0.5.1"></a>
## [0.5.1](https://github.com/ipfs/js-ipfs-http-response/compare/v0.5.0...v0.5.1) (2020-06-30)


### Bug Fixes

* **ci:** add empty commit to fix lint checks on master ([1db03b0](https://github.com/ipfs/js-ipfs-http-response/commit/1db03b0))



<a name="0.5.0"></a>
# [0.5.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.4.0...v0.5.0) (2020-01-07)


### Code Refactoring

* 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))


### BREAKING CHANGES

* Switch to using async/await and async iterators.



<a name="0.4.0"></a>
# [0.4.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.3.1...v0.4.0) (2019-10-14)


### Chores

* 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))


### BREAKING CHANGES

* All places in the API that used callbacks are now replaced with async/await

Co-authored-by: PedroMiguelSS <[email protected]>



<a name="0.3.1"></a>
## [0.3.1](https://github.com/ipfs/js-ipfs-http-response/compare/v0.2.2...v0.3.1) (2019-06-06)


### Bug Fixes

* 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))


### Chores

* 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))


### Features

* 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))


### BREAKING CHANGES

* v1 CIDs created by this module now default to base32 encoding when stringified

Not a direct dependency of this module but ipld-dag-pb changed the
case of some property names that are used by this module.

License: MIT
Signed-off-by: Alan Shaw <[email protected]>



<a name="0.3.0"></a>
## [0.3.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.2.2...v0.3.0) (2019-05-21)

BREAKING CHANGE: v1 CIDs created by this module now default to base32 encoding when stringified

Not a direct dependency of this module but ipld-dag-pb changed the
case of some property names that are used by this module.

<a name="0.2.2"></a>
## [0.2.2](https://github.com/ipfs/js-ipfs-http-response/compare/v0.2.1...v0.2.2) (2019-01-19)



<a name="0.2.1"></a>
## [0.2.1](https://github.com/ipfs/js-ipfs-http-response/compare/v0.1.4...v0.2.1) (2018-11-09)


### Bug Fixes

* 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))



<a name="0.2.0"></a>
## [0.2.0](https://github.com/ipfs/js-ipfs-http-response/compare/v0.1.4...v0.2.0) (2018-09-28)



<a name="0.1.4"></a>
## [0.1.4](https://github.com/ipfs/js-ipfs-http-response/compare/v0.1.3...v0.1.4) (2018-08-02)


### Bug Fixes

* 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))



<a name="0.1.3"></a>
## [0.1.3](https://github.com/ipfs/js-ipfs-http-response/compare/v0.1.2...v0.1.3) (2018-07-28)


### Bug Fixes

* 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))



<a name="0.1.2"></a>
## 0.1.2 (2018-06-01)


### Bug Fixes

* update package name ([91b99b3](https://github.com/ipfs/js-ipfs-http-response/commit/91b99b3))


### Features

* export resolver ([d9e56b8](https://github.com/ipfs/js-ipfs-http-response/commit/d9e56b8))
* initial implementation ([d9d0c08](https://github.com/ipfs/js-ipfs-http-response/commit/d9d0c08))



21 changes: 21 additions & 0 deletions packages/ipfs-http-response/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 IPFS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
56 changes: 56 additions & 0 deletions packages/ipfs-http-response/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# js-ipfs-http-response

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![standard-readme](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

> Creates an HTTP response from an IPFS Hash
## Lead Maintainer

[Vasco Santos](https://github.com/vasco-santos).

### Installation

> npm install ipfs-http-response
## Usage


### Creating HTTP Response

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.

```js
import { getResponse } from 'ipfs-http-response'

const result = await getResponse(ipfsNode, ipfsPath)
console.log(result)
```

### Using protocol-agnostic resolver

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:

```js
import { resolver } from 'ipfs-http-response'

const result = await resolver.cid(ipfsNode, ipfsPath)
console.log(result)
```

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`:


```js
import { resolver } from 'ipfs-http-response'

const result = await resolver.directory(ipfsNode, ipfsPath, cid)
console.log(result)
```

`result` will be either a `string` with HTML directory listing or an array with CIDs of `index` pages present in inspected directory.

![ipfs-http-response usage](docs/ipfs-http-response.png "ipfs-http-response usage")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 98 additions & 0 deletions packages/ipfs-http-response/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"name": "ipfs-http-response",
"version": "1.0.1",
"description": "Creates an HTTP response from an IPFS Hash",
"leadMaintainer": "Vasco Santos <[email protected]>",
"main": "src/index.js",
"types": "types/src/index.d.ts",
"typesVersions": {
"*": {
"*": [
"types/*",
"types/src/*"
],
"types/*": [
"types/*",
"types/src/*"
]
}
},
"type": "module",
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
"sourceType": "module"
}
},
"exports": {
".": {
"import": "./src/index.js"
}
},
"publishConfig": {
"directory": "dist"
},
"scripts": {
"lint": "aegir ts -p check && aegir lint",
"build": "aegir build",
"release": "aegir release --target node",
"release-minor": "aegir release --type minor --target node",
"release-major": "aegir release --type major --target node",
"pretest": "aegir build --esm-tests",
"test": "aegir test -t node",
"test:node": "aegir test -t node"
},
"browser": {
"file-type": "file-type/browser",
"fs": false
},
"repository": {
"type": "git",
"url": "git+https://github.com/ipfs/js-ipfs-http-response.git"
},
"keywords": [
"ipfs",
"http",
"response"
],
"author": "Vasco Santos <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/ipfs/js-ipfs-http-response/issues"
},
"homepage": "https://github.com/ipfs/js-ipfs-http-response#readme",
"dependencies": {
"debug": "^4.3.1",
"ejs": "^3.1.6",
"file-type": "^16.0.0",
"filesize": "^8.0.0",
"it-buffer": "^0.1.1",
"it-concat": "^2.0.0",
"it-reader": "^3.0.0",
"it-to-stream": "^1.0.0",
"mime-types": "^2.1.30",
"multiformats": "^9.2.0",
"p-try-each": "^1.0.1"
},
"devDependencies": {
"@types/ejs": "^3.1.0",
"aegir": "^35.0.3",
"get-stream": "^6.0.0",
"ipfs-core": "^0.10.5",
"ipfsd-ctl": "^10.0.1",
"it-all": "^1.0.5",
"path": "^0.12.7",
"uint8arrays": "^3.0.0",
"util": "^0.12.3"
},
"contributors": [
"Vasco Santos <[email protected]>",
"Alex Potsides <[email protected]>",
"Hector Sanjuan <[email protected]>",
"Marcin Rataj <[email protected]>",
"André Cruz <[email protected]>",
"Irakli Gozalishvili <[email protected]>",
"Alan Shaw <[email protected]>",
"Pedro Santos <[email protected]>"
]
}
Loading

0 comments on commit 7bac678

Please sign in to comment.