Skip to content

Commit

Permalink
feat: add support for custom http and https agents (#966)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cafe137 authored Oct 24, 2024
1 parent 6e695b7 commit 7c5662b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ const bee = new Bee('http://localhost:1633')
const uploadResult = await bee.uploadFilesFromDirectory(batchId, './path/to/gallery/')
```

### Customize http/https agent and headers

```js
const bee = new Bee('http://localhost:1633', {
httpAgent: new http.Agent({ keepAlive: true }),
httpsAgent: new https.Agent({ keepAlive: true }),
headers: {
Authorization: 'Basic ' + Buffer.from('username:password').toString('base64'),
},
})
```

[**Check out our examples repo for some more ideas on how to use `bee-js`**](https://github.com/ethersphere/examples-js)

## Documentation
Expand Down
2 changes: 2 additions & 0 deletions src/bee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ export class Bee {
timeout: options?.timeout ?? false,
headers: options?.headers,
onRequest: options?.onRequest,
httpAgent: options?.httpAgent,
httpsAgent: options?.httpsAgent,
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export type BeeRequestOptions = {
timeout?: number | false
headers?: Record<string, string>
onRequest?: (request: BeeRequest) => void
httpAgent?: any

Check warning on line 90 in src/types/index.ts

View workflow job for this annotation

GitHub Actions / check (16.x)

Unexpected any. Specify a different type
httpsAgent?: any

Check warning on line 91 in src/types/index.ts

View workflow job for this annotation

GitHub Actions / check (16.x)

Unexpected any. Specify a different type
}

export interface BeeOptions extends BeeRequestOptions {
Expand Down

0 comments on commit 7c5662b

Please sign in to comment.