Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cloudflare eth resolver
Browse files Browse the repository at this point in the history
SgtPooki committed Feb 27, 2024
1 parent 8f2ccbf commit c62bce4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib/heliaFetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { dnsJsonOverHttps } from '@helia/ipns/dns-resolvers'
import { delegatedHTTPRouting } from '@helia/routers'
import { createVerifiedFetch, type ContentTypeParser } from '@helia/verified-fetch'
import { fileTypeFromBuffer } from '@sgtpooki/file-type'
import { getConfig } from './config-db'
import type { Helia } from '@helia/interface'

export interface HeliaFetchOptions {
@@ -126,7 +129,12 @@ function changeCssFontPath (path: string): string {
*
*/
export async function heliaFetch ({ path, helia, signal, headers, id, protocol }: HeliaFetchOptions): Promise<Response> {
const verifiedFetch = await createVerifiedFetch(helia, {
const config = await getConfig()
const verifiedFetch = await createVerifiedFetch({
gateways: ['https://trustless-gateway.link', ...config.gateways],
routers: ['https://delegated-ipfs.dev', ...config.routers],
dnsResolvers: ['https://resolver.cloudflare-eth.com/dns-query'].map(dnsJsonOverHttps)
}, {
contentTypeParser
})

0 comments on commit c62bce4

Please sign in to comment.