1.5.0 • Published 11 months ago

ipfs-gateway-race v1.5.0

Weekly downloads
-
License
Apache-2.0 OR MIT
Repository
-
Last release
11 months ago

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

1.5.0

11 months ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.1

1 year ago

1.3.0

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago