@helia/http 3.1.3 → 3.1.4-1361bfa5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,7 +30,7 @@ repo and examine the changes made.
30
30
 
31
31
  -->
32
32
 
33
- Exports a `createHeliaHTTP` function that returns an object that implements a lightweight version of the Helia API that functions only over HTTP.
33
+ Exports a `withHTTP` function configures a Helia node that with block brokers and gateways that only run over HTTP.
34
34
 
35
35
  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/).
36
36
 
@@ -39,38 +39,42 @@ Pass it to other modules like @helia/unixfs to fetch files from the distributed
39
39
  ## Example
40
40
 
41
41
  ```typescript
42
- import { createHeliaHTTP } from '@helia/http'
42
+ import { withHTTP } from '@helia/http'
43
43
  import { unixfs } from '@helia/unixfs'
44
+ import { createHelia } from 'helia'
44
45
  import { CID } from 'multiformats/cid'
45
46
 
46
- const helia = await createHeliaHTTP()
47
+ const helia = await withHTTP(createHelia()).start()
47
48
 
48
49
  const fs = unixfs(helia)
49
50
  fs.cat(CID.parse('bafyFoo'))
50
51
  ```
51
52
 
52
- ## Example - with custom gateways and delegated routing endpoints
53
+ ## Example - without using this module
54
+
55
+ It's possible to manually configure your node without using this module.
53
56
 
54
57
  ```typescript
55
- import { createHeliaHTTP } from '@helia/http'
56
- import { trustlessGateway } from '@helia/block-brokers'
57
- import { delegatedHTTPRouting, httpGatewayRouting } from '@helia/routers'
58
+ import { createHelia } from 'helia'
59
+ import { trustlessGatewayBlockBroker } from '@helia/trustless-gateway-client'
60
+ import { fallbackRouter } from '@helia/fallback-router'
61
+ import { delegatedHTTPRouter } from '@helia/delegated-http-routing-client'
58
62
  import { unixfs } from '@helia/unixfs'
59
63
  import { CID } from 'multiformats/cid'
60
64
 
61
- const helia = await createHeliaHTTP({
65
+ const helia = await createHelia({
62
66
  blockBrokers: [
63
- trustlessGateway()
67
+ trustlessGatewayBlockBroker()
64
68
  ],
65
69
  routers: [
66
- delegatedHTTPRouting({
70
+ delegatedHTTPRouter({
67
71
  url: 'https://delegated-ipfs.dev'
68
72
  }),
69
- httpGatewayRouting({
73
+ fallbackRouter({
70
74
  gateways: ['https://cloudflare-ipfs.com', 'https://ipfs.io']
71
75
  })
72
76
  ]
73
- })
77
+ }).start()
74
78
 
75
79
  const fs = unixfs(helia)
76
80
  fs.cat(CID.parse('bafyFoo'))