ipfs-gateway-race
v1.6.0
Published
Races given IPFS Gateways to resolve provided CID
Downloads
20
Readme
ipfs-gateway-race
Install
npm install ipfs-gateway-race
Usage
Import the library in your application and create a gateway racer like:
import { createGatewayRacer } from 'ipfs-gateway-race'
const gwRacer = createGatewayRacer(
['https://ipfs.io', 'https://cf-ipfs.com']
)
Get
Get a IPFS response by given CID.
interface IpfsGatewayRaceGetOptions {
pathname?: string
headers?: Headers
noAbortRequestsOnWinner?: boolean
onRaceEnd?: (gwResponsePromises: GatewayResponsePromise[], winnerResponse: GatewayResponse | undefined) => void
}
get(cid: string, options: IpfsGatewayRaceGetOptions): Promise<Response>
Example:
import { createGatewayRacer } from 'ipfs-gateway-race'
const gwRacer = createGatewayRacer(['https://ipfs.io', 'https://cf-ipfs.com'])
const response = await gwRacer.get(
'bafybeiedv7sowwxamly4oicivudp45rsfvbklnf3fvbvonxrwoxqylhtwq',
{ pathname: '/0.json' }
)
Contributing
Feel free to join in. All welcome. Open an issue!
If you're opening a pull request, please see the guidelines in DEVELOPMENT.md on structuring your commit messages so that your PR will be compatible with our release process.
License
Dual-licensed under MIT + Apache 2.0