Skip to content
This repository was archived by the owner on Sep 28, 2021. It is now read-only.
/ js-ipfs-http-response Public archive

Creates an HTTP response from an IPFS Hash

License

Notifications You must be signed in to change notification settings

ipfs/js-ipfs-http-response

Folders and files

NameName
Last commit message
Last commit date

Latest commit

88a251d · Sep 8, 2021

History

94 Commits
Sep 7, 2021
May 24, 2018
Sep 7, 2021
Sep 7, 2021
Sep 7, 2021
Jan 31, 2019
Sep 8, 2021
May 22, 2018
Sep 7, 2021
Sep 8, 2021
Sep 7, 2021

Repository files navigation

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.

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:

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:

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