11import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
22import { NotFoundError } from '@libp2p/interface'
3- import { defaultLogger } from '@libp2p/logger'
43import { marshalIPNSRecord , multihashFromIPNSRoutingKey , unmarshalIPNSRecord } from 'ipns'
54import first from 'it-first'
65import map from 'it-map'
@@ -22,7 +21,7 @@ function isIPNSKey (key: Uint8Array): boolean {
2221class DelegatedHTTPRouter implements Routing {
2322 private readonly client : DelegatedRoutingV1HttpApiClient
2423
25- constructor ( components : DelegatedRoutingV1HttpApiClientComponents , init : DelegatedRoutingV1HttpApiClientInit & { url : string | URL } ) {
24+ constructor ( components : DelegatedRoutingV1HttpApiClientComponents , init : DelegatedRoutingV1HttpApiClientInit ) {
2625 this . client = delegatedRoutingV1HttpApiClient ( init ) ( components )
2726 }
2827
@@ -105,24 +104,6 @@ class DelegatedHTTPRouter implements Routing {
105104/**
106105 * Creates a Helia Router that connects to an endpoint that supports the [Delegated Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/) spec.
107106 */
108- export function delegatedHTTPRouting ( init : DelegatedRoutingV1HttpApiClientInit & { url : string | URL } ) : ( components : any ) => Routing
109- /**
110- * @deprecated Use `delegatedHTTPRouting(init)` instead
111- */
112- export function delegatedHTTPRouting ( url : string | URL , init ?: DelegatedRoutingV1HttpApiClientInit ) : Routing
113- export function delegatedHTTPRouting ( url : string | URL | ( DelegatedRoutingV1HttpApiClientInit & { url : string | URL } ) , init ?: DelegatedRoutingV1HttpApiClientInit ) : Routing | ( ( components : any ) => Routing ) {
114- if ( typeof url === 'string' || url instanceof URL ) {
115- return new DelegatedHTTPRouter ( {
116- logger : defaultLogger ( )
117- } , {
118- ...delegatedHTTPRoutingDefaults ( ) ,
119- ...init ,
120- url : new URL ( url )
121- } )
122- }
123-
124- return ( components : any ) => new DelegatedHTTPRouter ( components , {
125- ...delegatedHTTPRoutingDefaults ( ) ,
126- ...url
127- } )
107+ export function delegatedHTTPRouting ( init : DelegatedRoutingV1HttpApiClientInit ) : ( components : any ) => Routing {
108+ return ( components : any ) => new DelegatedHTTPRouter ( components , delegatedHTTPRoutingDefaults ( init ) )
128109}
0 commit comments