|
128 | 128 | * |
129 | 129 | * const fetch = await createVerifiedFetch({ |
130 | 130 | * gateways: ['https://trustless-gateway.link'], |
131 | | - * routers: ['http://delegated-ipfs.dev'], |
| 131 | + * routers: ['http://delegated-ipfs.dev'] |
| 132 | + * }, { |
132 | 133 | * contentTypeParser: async (bytes) => { |
133 | 134 | * // call to some magic-byte recognition library like magic-bytes, file-type, or your own custom byte recognition |
134 | 135 | * const result = await fileTypeFromBuffer(bytes) |
@@ -285,10 +286,12 @@ export interface VerifiedFetch { |
285 | 286 | * Instead of passing a Helia instance, you can pass a list of gateways and |
286 | 287 | * routers, and a HeliaHTTP instance will be created for you. |
287 | 288 | */ |
288 | | -export interface CreateVerifiedFetchOptions { |
| 289 | +export interface CreateVerifiedFetchInit { |
289 | 290 | gateways: string[] |
290 | 291 | routers?: string[] |
| 292 | +} |
291 | 293 |
|
| 294 | +export interface CreateVerifiedFetchOptions { |
292 | 295 | /** |
293 | 296 | * A function to handle parsing content type from bytes. The function you |
294 | 297 | * provide will be passed the first set of bytes we receive from the network, |
@@ -338,11 +341,10 @@ export interface VerifiedFetchInit extends RequestInit, ProgressOptions<BubbledP |
338 | 341 | /** |
339 | 342 | * Create and return a Helia node |
340 | 343 | */ |
341 | | -export async function createVerifiedFetch (init?: Helia | CreateVerifiedFetchOptions): Promise<VerifiedFetch> { |
342 | | - let contentTypeParser: ContentTypeParser | undefined |
| 344 | +export async function createVerifiedFetch (init?: Helia | CreateVerifiedFetchInit, options?: CreateVerifiedFetchOptions): Promise<VerifiedFetch> { |
| 345 | + const contentTypeParser: ContentTypeParser | undefined = options?.contentTypeParser |
343 | 346 |
|
344 | 347 | if (!isHelia(init)) { |
345 | | - contentTypeParser = init?.contentTypeParser |
346 | 348 | init = await createHeliaHTTP({ |
347 | 349 | blockBrokers: [ |
348 | 350 | trustlessGateway({ |
|
0 commit comments