11/**
22 * @packageDocumentation
33 *
4- * Create a Helia node .
4+ * Create a client to use with a Routing V1 HTTP API server .
55 *
66 * @example
77 *
88 * ```typescript
9- * import { MemoryDatastore } from 'datastore-core'
10- * import { MemoryBlockstore } from 'blockstore-core'
11- * import { createHelia } from 'helia'
12- * import { unixfs } from '@helia/unixfs'
9+ * import { createRoutingV1HttpApiClient } from '@helia/routing-v1-http-api-client'
1310 * import { CID } from 'multiformats/cid'
1411 *
15- * const node = await createHelia({
16- * blockstore: new MemoryBlockstore(),
17- * datastore: new MemoryDatastore()
18- * })
19- * const fs = unixfs(node)
20- * fs.cat(CID.parse('bafyFoo'))
12+ * const client = createRoutingV1HttpApiClient(new URL('https://example.org'))
13+ *
14+ * for await (const prov of getProviders(CID.parse('QmFoo'))) {
15+ * // ...
16+ * }
2117 * ```
2218 */
2319
@@ -41,12 +37,21 @@ export interface RoutingV1HttpApiClientInit {
4137}
4238
4339export interface RoutingV1HttpApiClient {
40+ /**
41+ * Returns an async generator of PeerInfos that can provide the content
42+ * for the passed CID
43+ */
4444 getProviders : ( cid : CID , options ?: AbortOptions ) => AsyncGenerator < PeerInfo >
45+
46+ /**
47+ * Shut down any currently running HTTP requests and clear up any resources
48+ * that are in use
49+ */
4550 stop : ( ) => void
4651}
4752
4853/**
49- * Create and return a Helia node
54+ * Create and return a client to use with a Routing V1 HTTP API server
5055 */
5156export function createRoutingV1HttpApiClient ( url : URL , init : RoutingV1HttpApiClientInit = { } ) : RoutingV1HttpApiClient {
5257 return new DefaultRoutingV1HttpApiClient ( url , init )
0 commit comments