@helia/http
Version:
A lightweight implementation of IPFS over HTTP in JavaScript
66 lines • 2.52 kB
TypeScript
/**
* @packageDocumentation
*
* Exports a `createHeliaHTTP` function that returns an object that implements a lightweight version of the {@link Helia} API that functions only over HTTP.
*
* By default, content and peer routing are requests are resolved using the [Delegated HTTP Routing API](https://specs.ipfs.tech/routing/http-routing-v1/) and blocks are fetched from [Trustless Gateways](https://specs.ipfs.tech/http-gateways/trustless-gateway/).
*
* Pass it to other modules like {@link https://www.npmjs.com/package/@helia/unixfs | @helia/unixfs} to fetch files from the distributed web.
*
* @example
*
* ```typescript
* import { createHeliaHTTP } from '@helia/http'
* import { unixfs } from '@helia/unixfs'
* import { CID } from 'multiformats/cid'
*
* const helia = await createHeliaHTTP()
*
* const fs = unixfs(helia)
* fs.cat(CID.parse('bafyFoo'))
* ```
* @example with custom gateways and delegated routing endpoints
* ```typescript
* import { createHeliaHTTP } from '@helia/http'
* import { trustlessGateway } from '@helia/block-brokers'
* import { delegatedHTTPRouting, httpGatewayRouting } from '@helia/routers'
* import { unixfs } from '@helia/unixfs'
* import { CID } from 'multiformats/cid'
*
* const helia = await createHeliaHTTP({
* blockBrokers: [
* trustlessGateway()
* ],
* routers: [
* delegatedHTTPRouting({
* url: 'https://delegated-ipfs.dev'
* }),
* httpGatewayRouting({
* gateways: ['https://cloudflare-ipfs.com', 'https://ipfs.io']
* })
* ]
* })
*
* const fs = unixfs(helia)
* fs.cat(CID.parse('bafyFoo'))
* ```
*/
import type { DefaultLibp2pHTTPServices } from './utils/libp2p-defaults.ts';
import type { Libp2pHTTPDefaultOptions } from './utils/libp2p.ts';
import type { Helia } from '@helia/interface';
import type { HeliaInit } from '@helia/utils';
import type { Libp2p } from '@libp2p/interface';
export * from '@helia/interface';
export type HeliaHTTPInit = HeliaInit<Libp2p<DefaultLibp2pHTTPServices>>;
export type { DefaultLibp2pHTTPServices, Libp2pHTTPDefaultOptions };
/**
* Create and return the default options used to create a Helia node
*/
export declare function heliaDefaults<T extends Libp2p>(init?: Partial<HeliaInit<T>>): Promise<Omit<HeliaInit<T>, 'libp2p'> & {
libp2p: T;
}>;
/**
* Create and return a Helia node
*/
export declare function createHeliaHTTP(init?: Partial<HeliaHTTPInit>): Promise<Helia<Libp2p<DefaultLibp2pHTTPServices>>>;
//# sourceMappingURL=index.d.ts.map