This version has been deprecated

Author message:

js-IPFS has been deprecated in favour of Helia - please see https://github.com/ipfs/js-ipfs/issues/4336 for details

ipfs-http-response
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

js-ipfs-http-response

standard-readme js-standard-style

Creates an HTTP response from an IPFS Hash

Lead Maintainer

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.

const { getResponse } = require('ipfs-http-response')

getResponse(ipfsNode, ipfsPath)
  .then((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:

const { resolver } = require('ipfs-http-response')

resolver.cid(ipfsNode, ipfsPath)
  .then((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:

const { resolver } = require('ipfs-http-response')

resolver.directory(ipfsNode, ipfsPath, cid)
  .then((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

Readme

Keywords

Package Sidebar

Install

npm i ipfs-http-response@0.2.1

Version

0.2.1

License

MIT

Unpacked Size

1.79 MB

Total Files

26

Last publish

Collaborators

  • achingbrain
  • npm-service-account-ipfs