Skip to content

Commit

Permalink
chore: improve readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
2color committed Jan 16, 2024
1 parent 9f772c5 commit a558fc4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/http/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* 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
Expand All @@ -17,6 +19,28 @@
* 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 } from '@helia/routers'
* import { unixfs } from '@helia/unixfs'
* import { CID } from 'multiformats/cid'
*
* const helia = await createHeliaHTTP({
* blockBrokers: [
* trustlessGateway({
* gateways: ['https://cloudflare-ipfs.com', 'https://ipfs.io'],
* }),
* ],
* routers: [
* delegatedHTTPRouting('https://delegated-ipfs.dev')
* ]
* })
*
* const fs = unixfs(helia)
* fs.cat(CID.parse('bafyFoo'))
* ```
*/

import { trustlessGateway } from '@helia/block-brokers'
Expand Down
5 changes: 5 additions & 0 deletions packages/routers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
/**
* @packageDocumentation
*
* Abstraction layer over different content and peer routing mechanisms.
*/
export { delegatedHTTPRouting } from './delegated-http-routing.js'
export { libp2pRouting } from './libp2p-routing.js'

0 comments on commit a558fc4

Please sign in to comment.