# ipfs-http-response

> Creates an HTTP response from an IPFS Hash

Latest version **6.0.1** (published 2023-05-25) · Apache-2.0 OR MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install ipfs-http-response
pnpm add ipfs-http-response
yarn add ipfs-http-response
bun add ipfs-http-response
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 6.0.1 |
| Published | 2023-05-25 |
| First published | 2018-05-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16.0.0 |
| Dependencies | 9 |
| Unpacked size | 221.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7389 |
| Author | Vasco Santos |
| Maintainers | achingbrain, vascosantos, ipfs-npm-publisher-bot, npm-service-account-ipfs |
| Keywords | http, ipfs, response |

## Links

- npm: https://www.npmjs.com/package/ipfs-http-response
- Repository: https://github.com/ipfs/js-ipfs
- Homepage: https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-response#readme
- Issues: https://github.com/ipfs/js-ipfs/issues
- npm.io page: https://npm.io/package/ipfs-http-response

## Dependencies (9)

- [ejs](https://npm.io/package/ejs.md) ^3.1.6
- [it-map](https://npm.io/package/it-map.md) ^2.0.0
- [filesize](https://npm.io/package/filesize.md) ^10.0.5
- [file-type](https://npm.io/package/file-type.md) ^18.0.0
- [it-reader](https://npm.io/package/it-reader.md) ^6.0.1
- [mime-types](https://npm.io/package/mime-types.md) ^2.1.30
- [p-try-each](https://npm.io/package/p-try-each.md) ^1.0.1
- [it-to-stream](https://npm.io/package/it-to-stream.md) ^1.0.0
- [@libp2p/logger](https://npm.io/package/@libp2p/logger.md) ^2.0.5

## Recent versions

- 6.0.1 (latest) — 2023-05-25
- 6.0.0-7b79c1b8 (next) — 2023-05-25
- 6.0.0-6d95ce08 — 2023-05-25
- 6.0.0-4694e806 — 2023-05-25
- 6.0.0-e64813f6 — 2023-05-24
- 6.0.0-b64d4af0 — 2023-02-01
- 6.0.0-3bcabe38 — 2023-01-17
- 6.0.0-ab02e8f8 — 2023-01-17
- 6.0.0-6eeb1be5 — 2023-01-13
- 6.0.0 — 2023-01-12
- 5.0.0-d1c3abb3 — 2023-01-11
- 5.0.0-fa578bac — 2023-01-11
- 5.0.0-789ee585 — 2023-01-11
- 5.0.0-4b4c124c — 2023-01-11
- 5.0.0-5f73ecad — 2023-01-10
- … 121 more at https://npm.io/package/ipfs-http-response/versions

## README

> # ⛔️ DEPRECATED: [js-IPFS](https://github.com/ipfs/js-ipfs) has been superseded by [Helia](https://github.com/ipfs/helia)
>
> 📚 [Learn more about this deprecation](https://github.com/ipfs/js-ipfs/issues/4336) or [how to migrate](https://github.com/ipfs/helia/wiki/Migrating-from-js-IPFS)
>
> ⚠️ If you continue using this repo, please note that security fixes will not be provided

# ipfs-http-response <!-- omit in toc -->

[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs)
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-ipfs/test.yml?branch=master\&style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/test.yml?query=branch%3Amaster)

> Creates an HTTP response from an IPFS Hash

## Table of contents <!-- omit in toc -->

- [Install](#install)
- [Usage](#usage)
  - [Creating HTTP Response](#creating-http-response)
  - [Using protocol-agnostic resolver](#using-protocol-agnostic-resolver)
- [License](#license)
- [Contribute](#contribute)

## Install

```console
$ npm i 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")

## License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribute

Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues).

Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.

Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)

---
_Source: https://npm.io/package/ipfs-http-response · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
