Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Aug 7, 2023
1 parent 0589727 commit 2e645c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
29 changes: 17 additions & 12 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
/**
* @packageDocumentation
*
* Create a Helia node.
* Create a client to use with a Routing V1 HTTP API server.
*
* @example
*
* ```typescript
* import { MemoryDatastore } from 'datastore-core'
* import { MemoryBlockstore } from 'blockstore-core'
* import { createHelia } from 'helia'
* import { unixfs } from '@helia/unixfs'
* import { createRoutingV1HttpApiClient } from '@helia/routing-v1-http-api-client'
* import { CID } from 'multiformats/cid'
*
* const node = await createHelia({
* blockstore: new MemoryBlockstore(),
* datastore: new MemoryDatastore()
* })
* const fs = unixfs(node)
* fs.cat(CID.parse('bafyFoo'))
* const client = createRoutingV1HttpApiClient(new URL('https://example.org'))
*
* for await (const prov of getProviders(CID.parse('QmFoo'))) {
* // ...
* }
* ```
*/

Expand All @@ -41,12 +37,21 @@ export interface RoutingV1HttpApiClientInit {
}

export interface RoutingV1HttpApiClient {
/**
* Returns an async generator of PeerInfos that can provide the content
* for the passed CID
*/
getProviders: (cid: CID, options?: AbortOptions) => AsyncGenerator<PeerInfo>

/**
* Shut down any currently running HTTP requests and clear up any resources
* that are in use
*/
stop: () => void
}

/**
* Create and return a Helia node
* Create and return a client to use with a Routing V1 HTTP API server
*/
export function createRoutingV1HttpApiClient (url: URL, init: RoutingV1HttpApiClientInit = {}): RoutingV1HttpApiClient {
return new DefaultRoutingV1HttpApiClient(url, init)
Expand Down
5 changes: 1 addition & 4 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
*
* const helia = await createHelia()
* const server = await createRoutingV1HttpApiServer(helia, {
* fastify: {
* // fastify options
* },
* listen: {
* // fastify listen options
* }
Expand Down Expand Up @@ -68,7 +65,7 @@ export interface ServerInit {
}

/**
* Create and return a Helia node
* Create and return a Routing V1 HTTP API server
*/
export async function createRoutingV1HttpApiServer (helia: Helia, init: ServerInit = {}): Promise<FastifyInstance> {
const server = init.fastify ?? fastify()
Expand Down

0 comments on commit 2e645c0

Please sign in to comment.