diff --git a/package.json b/package.json index 4515858..f105263 100644 --- a/package.json +++ b/package.json @@ -29,13 +29,13 @@ "generate": "aegir run generate", "build": "aegir run build", "lint": "aegir run lint", - "docs": "NODE_OPTIONS=--max_old_space_size=4096 aegir docs", + "docs": "NODE_OPTIONS=--max_old_space_size=4096 aegir docs -- --exclude packages/interop", "docs:no-publish": "npm run docs -- --publish false", "dep-check": "aegir run dep-check", - "release": "npm run docs:no-publish && aegir run release && npm run docs" + "release": "npm run docs:no-publish && aegir run release && npm run docs -- --exclude packages/interop" }, "devDependencies": { - "aegir": "^39.0.4" + "aegir": "^40.0.8" }, "type": "module", "workspaces": [ diff --git a/packages/client/package.json b/packages/client/package.json index 4f210bf..5ae6a4a 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -144,10 +144,7 @@ }, "devDependencies": { "@libp2p/peer-id-factory": "^2.0.3", - "aegir": "^39.0.4", + "aegir": "^40.0.8", "body-parser": "^1.20.2" - }, - "typedoc": { - "entryPoint": "./src/index.ts" } } diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index 2886d1d..9290419 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -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'))) { + * // ... + * } * ``` */ @@ -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 + + /** + * 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) diff --git a/packages/client/typedoc.json b/packages/client/typedoc.json new file mode 100644 index 0000000..f599dc7 --- /dev/null +++ b/packages/client/typedoc.json @@ -0,0 +1,5 @@ +{ + "entryPoints": [ + "./src/index.ts" + ] +} diff --git a/packages/interop/README.md b/packages/interop/README.md index 15bf764..4419c69 100644 --- a/packages/interop/README.md +++ b/packages/interop/README.md @@ -16,7 +16,6 @@ ## Table of contents - [Install](#install) -- [API Docs](#api-docs) - [License](#license) - [Contribute](#contribute) @@ -26,10 +25,6 @@ $ npm i @helia/routing-v1-http-api-interop ``` -## API Docs - -- - ## License Licensed under either of diff --git a/packages/interop/package.json b/packages/interop/package.json index 57a2d7f..c41403c 100644 --- a/packages/interop/package.json +++ b/packages/interop/package.json @@ -51,13 +51,10 @@ "@helia/interface": "^1.1.1", "@libp2p/interface-libp2p": "^3.2.0", "@libp2p/kad-dht": "^9.3.6", - "aegir": "^39.0.4", + "aegir": "^40.0.8", "fastify": "^4.17.0", "libp2p": "^0.45.4", "multiformats": "^11.0.2" }, - "private": true, - "typedoc": { - "entryPoint": "./src/index.ts" - } + "private": true } diff --git a/packages/server/package.json b/packages/server/package.json index 73e2711..5b0095d 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -160,11 +160,8 @@ "@libp2p/peer-id-factory": "^2.0.3", "@multiformats/multiaddr": "^12.1.3", "@types/sinon": "^10.0.15", - "aegir": "^39.0.4", + "aegir": "^40.0.8", "sinon": "^15.1.0", "sinon-ts": "^1.0.0" - }, - "typedoc": { - "entryPoint": "./src/index.ts" } } diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index d5d47cd..1bcc253 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -11,9 +11,6 @@ * * const helia = await createHelia() * const server = await createRoutingV1HttpApiServer(helia, { - * fastify: { - * // fastify options - * }, * listen: { * // fastify listen options * } @@ -55,22 +52,23 @@ */ import cors from '@fastify/cors' -import fastify, { type FastifyListenOptions, type FastifyHttpOptions, type FastifyHttpsOptions, type FastifyInstance } from 'fastify' +import fastify, { + type FastifyListenOptions, + type FastifyInstance +} from 'fastify' import routes from './routes/index.js' import type { Helia } from '@helia/interface' -import type * as http from 'node:http' -import type * as https from 'node:https' export interface ServerInit { - fastify?: FastifyHttpOptions | FastifyHttpsOptions + fastify?: FastifyInstance listen?: FastifyListenOptions } /** - * Create and return a Helia node + * Create and return a Routing V1 HTTP API server */ export async function createRoutingV1HttpApiServer (helia: Helia, init: ServerInit = {}): Promise { - const server = fastify(init.fastify) + const server = init.fastify ?? fastify() await server.register(cors, { origin: '*', methods: ['GET', 'OPTIONS'], diff --git a/packages/server/typedoc.json b/packages/server/typedoc.json new file mode 100644 index 0000000..1e561cb --- /dev/null +++ b/packages/server/typedoc.json @@ -0,0 +1,6 @@ +{ + "entryPoints": [ + "./src/index.ts", + "./src/routes/index.ts" + ] +} diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 0000000..a3a51fe --- /dev/null +++ b/typedoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://typedoc.org/schema.json", + "name": "Helia Routing V1 HTTP API" +}