Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: @helia/verified-fetch init args are optional #412

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/verified-fetch/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,15 @@ export interface VerifiedFetchInit extends RequestInit, ProgressOptions<BubbledP
/**
* Create and return a Helia node
*/
export async function createVerifiedFetch (init: Helia | CreateVerifiedFetchWithOptions): Promise<VerifiedFetch> {
export async function createVerifiedFetch (init?: Helia | CreateVerifiedFetchWithOptions): Promise<VerifiedFetch> {
if (!isHelia(init)) {
init = await createHeliaHTTP({
blockBrokers: [
trustlessGateway({
gateways: init.gateways
gateways: init?.gateways
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just confirming for myself. if gateways is null, should be set to defaults via

this.gateways = (init.gateways ?? DEFAULT_TRUSTLESS_GATEWAYS)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the routers don't work in quite the same way though maybe they should.

})
],
routers: init.routers?.map((routerUrl) => delegatedHTTPRouting(routerUrl))
routers: (init?.routers ?? ['https://delegated-ipfs.dev']).map((routerUrl) => delegatedHTTPRouting(routerUrl))
})
}

Expand Down
7 changes: 7 additions & 0 deletions packages/verified-fetch/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@ describe('createVerifiedFetch', () => {
expect(verifiedFetch).to.be.ok()
await verifiedFetch.stop()
})

it('can be constructed with no options', async () => {
const verifiedFetch = await createVerifiedFetch()

expect(verifiedFetch).to.be.ok()
await verifiedFetch.stop()
})
})
Loading