Skip to content

Commit

Permalink
feat: add extraHTTPSOptions (#32)
Browse files Browse the repository at this point in the history
* feat: add extraHTTPSOptions and remove dummy dependency

* fix: bring back https polyfill
  • Loading branch information
ThallesP committed Mar 3, 2023
1 parent 128823d commit 75c42cf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"lint-staged": {
"*.ts": "eslint --cache --fix"
},
"packageManager": "yarn@3.2.4",
"dependencies": {
"https": "^1.0.0"
},
"packageManager": "yarn@3.2.4"
}
}
3 changes: 2 additions & 1 deletion src/CoinGeckoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class CoinGeckoClient {
*/
private async httpGet<T>(url: string) {
const { host, pathname, search } = new URL(url);
const options = {
const options: https.RequestOptions = {
host,
path: pathname + search,
method: "GET",
Expand All @@ -86,6 +86,7 @@ export class CoinGeckoClient {
Accept: "application/json",
},
timeout: this.options.timeout, // in ms
...this.options.extraHTTPSOptions,
};
const parseJson = (input: string) => {
try {
Expand Down
4 changes: 3 additions & 1 deletion src/Interface.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { RequestOptions } from 'https';
import { PLATFORMS } from './Enum';

export interface PingResponse {
Expand Down Expand Up @@ -536,7 +537,8 @@ export type GlobalDefiResponse = ResponseWithData<GlobalDefiData>;

export interface Options {
timeout?: number,
autoRetry?: boolean
autoRetry?: boolean,
extraHTTPSOptions?: RequestOptions
}

export interface HttpResponse<T> {
Expand Down

0 comments on commit 75c42cf

Please sign in to comment.