@@ -35,10 +35,10 @@ function getAuthFromCredentials(creds: NetworkCredentials): AxiosBasicCredential
3535 } ;
3636}
3737
38- function getFileInfo ( networkApiUrl : string , bucketId : string , fileId : string , opts ?: AxiosRequestConfig ) : Promise < FileInfo > {
38+ function getFileInfo ( bucketId : string , fileId : string , opts ?: AxiosRequestConfig ) : Promise < FileInfo > {
3939 const defaultOpts : AxiosRequestConfig = {
4040 method : 'GET' ,
41- url : `${ networkApiUrl } /buckets/${ bucketId } /files/${ fileId } /info` ,
41+ url : `${ process . env . BRIDGE_URL } /buckets/${ bucketId } /files/${ fileId } /info` ,
4242 maxContentLength : Infinity ,
4343 } ;
4444
@@ -52,8 +52,8 @@ function getFileInfo(networkApiUrl: string, bucketId: string, fileId: string, op
5252 } ) ;
5353}
5454
55- export function getFileInfoWithAuth ( networkApiUrl : string , bucketId : string , fileId : string , creds : NetworkCredentials ) : Promise < FileInfo > {
56- return getFileInfo ( networkApiUrl , bucketId , fileId , {
55+ export function getFileInfoWithAuth ( bucketId : string , fileId : string , creds : NetworkCredentials ) : Promise < FileInfo > {
56+ return getFileInfo ( bucketId , fileId , {
5757 auth : getAuthFromCredentials ( creds ) ,
5858 } ) ;
5959}
@@ -78,13 +78,7 @@ export interface Mirror {
7878 operation : string ;
7979}
8080
81- export async function getMirrors (
82- networkApiUrl : string ,
83- bucketId : string ,
84- fileId : string ,
85- creds : NetworkCredentials | null ,
86- token ?: string ,
87- ) : Promise < Mirror [ ] > {
81+ export async function getMirrors ( bucketId : string , fileId : string , creds : NetworkCredentials | null , token ?: string ) : Promise < Mirror [ ] > {
8882 const mirrors : Mirror [ ] = [ ] ;
8983 const limit = 3 ;
9084
@@ -95,7 +89,7 @@ export async function getMirrors(
9589 } ;
9690
9791 do {
98- results = ( await getFileMirrors ( networkApiUrl , bucketId , fileId , limit , mirrors . length , [ ] , requestConfig ) )
92+ results = ( await getFileMirrors ( bucketId , fileId , limit , mirrors . length , [ ] , requestConfig ) )
9993 . filter ( ( m ) => ! m . parity )
10094 . sort ( ( mA , mB ) => mA . index - mB . index ) ;
10195
@@ -110,7 +104,7 @@ export async function getMirrors(
110104 if ( farmerIsOk ) {
111105 mirror . farmer . address = mirror . farmer . address . trim ( ) ;
112106 } else {
113- mirrors [ mirror . index ] = await replaceMirror ( networkApiUrl , bucketId , fileId , mirror . index , [ ] , requestConfig ) ;
107+ mirrors [ mirror . index ] = await replaceMirror ( bucketId , fileId , mirror . index , [ ] , requestConfig ) ;
114108
115109 if ( ! isFarmerOk ( mirrors [ mirror . index ] . farmer ) ) {
116110 throw new Error ( 'Missing pointer for shard %s' + mirror . hash ) ;
@@ -126,7 +120,6 @@ export async function getMirrors(
126120}
127121
128122async function replaceMirror (
129- networkApiUrl : string ,
130123 bucketId : string ,
131124 fileId : string ,
132125 pointerIndex : number ,
@@ -137,7 +130,7 @@ async function replaceMirror(
137130 let mirror : Mirror ;
138131
139132 while ( ! mirrorIsOk ) {
140- const [ newMirror ] = await getFileMirrors ( networkApiUrl , bucketId , fileId , 1 , pointerIndex , excludeNodes , opts ) ;
133+ const [ newMirror ] = await getFileMirrors ( bucketId , fileId , 1 , pointerIndex , excludeNodes , opts ) ;
141134
142135 mirror = newMirror ;
143136 mirrorIsOk = newMirror . farmer && newMirror . farmer . nodeID && newMirror . farmer . port && newMirror . farmer . address ? true : false ;
@@ -148,7 +141,6 @@ async function replaceMirror(
148141}
149142
150143function getFileMirrors (
151- networkApiUrl : string ,
152144 bucketId : string ,
153145 fileId : string ,
154146 limit : number | 3 ,
@@ -157,7 +149,7 @@ function getFileMirrors(
157149 opts ?: AxiosRequestConfig ,
158150) : Promise < Mirror [ ] > {
159151 const excludeNodeIds : string = excludeNodes . join ( ',' ) ;
160- const path = `${ networkApiUrl } /buckets/${ bucketId } /files/${ fileId } ` ;
152+ const path = `${ process . env . BRIDGE_URL } /buckets/${ bucketId } /files/${ fileId } ` ;
161153 const queryParams = `?limit=${ limit } &skip=${ skip } &exclude=${ excludeNodeIds } ` ;
162154
163155 const defaultOpts : AxiosRequestConfig = {
0 commit comments