Skip to content

Commit

Permalink
chore: http2 option (#146)
Browse files Browse the repository at this point in the history
* chore: http2 option

* fix: http2 option

* fix: tests

* chore: changelog
  • Loading branch information
vladimirvolek committed Nov 22, 2021
1 parent 1c79539 commit 1b61b5c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.MD
Expand Up @@ -7,9 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

<!-- ### Added
### Added

- `addressesExtended` and `accountsAddressesTotal` endpoints -->
- http2 option (default true)

## ⚠️ Breaking changes

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@blockfrost/blockfrost-js",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.3",
"description": "A JavaScript/TypeScript SDK for interacting with the https://blockfrost.io API",
"keywords": [
"blockfrost",
Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Expand Up @@ -38,6 +38,7 @@ type OptionCombination2 = {
type AdditionalOptions = {
isTestnet?: boolean;
version?: number;
http2?: boolean;
userAgent?: string;
requestTimeout?: number;
retrySettings?: RequiredRetryOptions;
Expand All @@ -50,6 +51,7 @@ export interface ValidatedOptions {
customBackend?: string;
version: number;
requestTimeout: number;
http2?: boolean;
projectId?: string;
isTestnet?: boolean;
retrySettings?: RequiredRetryOptions;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/got.ts
Expand Up @@ -9,7 +9,7 @@ export const getInstance = (
got.extend({
prefixUrl: apiUrl,
responseType: 'json',
http2: true,
http2: options.http2,
headers: {
project_id: options.projectId,
userAgent: userAgent,
Expand Down
1 change: 1 addition & 0 deletions src/utils/index.ts
Expand Up @@ -39,6 +39,7 @@ export const validateOptions = (options?: Options): ValidatedOptions => {
projectId: options.projectId,
isTestnet: options.isTestnet,
version: options.version || DEFAULT_API_VERSION,
http2: options.http2 ?? true,
// see: https://github.com/sindresorhus/got/blob/main/documentation/7-retry.md#retry
retrySettings: options.retrySettings,
requestTimeout: options.requestTimeout ?? 20000, // 20 seconds
Expand Down
4 changes: 3 additions & 1 deletion test/tests/utils/utils.ts
Expand Up @@ -106,7 +106,8 @@ describe('utils', () => {
isTestnet: undefined,
projectId: 'xxx',
requestTimeout: 20000,
retry: undefined,
http2: true,
retryOptions: undefined,
version: 0,
});
});
Expand Down Expand Up @@ -163,6 +164,7 @@ describe('utils', () => {
customBackend: undefined,
isTestnet: undefined,
projectId: 'xxx',
http2: true,
requestTimeout: 1,
version: 0,
});
Expand Down

0 comments on commit 1b61b5c

Please sign in to comment.