8000 docs: Example for customizing fetch requests to trustless gateways by Dhruv-Varshney-developer · Pull Request #768 · ipfs/helia · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

docs: Example for customizing fetch requests to trustless gateways #768

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Dhruv-Varshney-developer

Title

docs: Example for customizing fetch requests to trustless gateways

Description

Add example code to the packages/block-brokers/README.md demonstrating how to customize the fetch requests sent to trustless gateways using the transformRequestInit option.This shows how to add authentication headers (such as JWT tokens) when using the TrustlessGatewayBlockBroker.

Completes #757 .

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

@Dhruv-Varshney-developer Dhruv-Varshney-developer requested a review from a team as a code owner March 24, 2025 00:13
Copy link
Member
@2color 2color left a comment

Choose a reason for hiding this comment

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

Please move the example to index.ts of the package, because the README file is generated automatically from it, and will be overwritten in the build.

For example, for the dag-json package, this is the source:

/**
* @packageDocumentation
*
* `@helia/dag-json` makes working with DAG-JSON {@link https://github.com/ipfs/helia Helia} simple & straightforward.
*
* See the {@link DAGJSON} interface for all available operations.
*
* @example
*
* ```typescript
* import { createHelia } from 'helia'
* import { dagJson } from '@helia/dag-json'
* import { CID } from 'multiformats/cid'
*
* const helia = await createHelia()
* const j = dagJson(helia)
*
* const cid = await j.add({
* hello: 'world'
* })
* const obj = await j.get(cid)
*
* console.info(obj)
* // { hello: 'world' }
* ```
*/

  • Make sure the style is consistent by using npx aegir lint and npx aegir lint -- --fix
  • To generate the readme run npx aegir docs

Also left some comments in line.

@Dhruv-Varshney-developer
Copy link
Author

Hi @2color,
I have made all the changes as suggested, including moving the example to index.ts, ensuring the README is generated correctly, and following the required styles with npx aegir lint --fix.

I’ve also added the example for createHelia({ blockBrokers: [...] }) as requested. Let me know if any more improvements are needed!

@Dhruv-Varshney-developer
Copy link
Author

Hi @2color ,
It would be helpful if you could review and merge it. Let me know if any improvements are needed from my end.
Thanks for your work!

@Dhruv-Varshney-developer
Copy link
Author

Hi @2color,
Is there something that needs improvement here?

Dhruv-Varshney-developer and others added 4 commits May 30, 2025 09:06
Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
@Dhruv-Varshney-developer
Copy link
Author

Hi @2color @SgtPooki ,
I have addressed all the requested changes:

  • Fixed the .cat() issue
  • Removed log statements
  • Updated labels - Applied appropriate labeling as requested
  • Generated documentation - README now reflects the corrected example

You can verify the working example at: https://github.com/Dhruv-Varshney-developer/test-example-helia

I've also updated the CID in the example to use bafkreife2klsil6kaxqhvmhgldpsvk5yutzm4i5bgjoq6fydefwtihnesa (contains "hello world") from the IPFS documentation to ensure the example works reliably for users.

The PR is now ready for review.
Please let me know if any additional improvements are needed.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0