Skip to content

Commit

Permalink
Catch any errors when instantiating https.Agent (#24)
Browse files Browse the repository at this point in the history
* Catch any errors when instantiating https.Agent

* Remove https.Agent completely
  • Loading branch information
dmoss18 authored Feb 28, 2024
1 parent 1bcf9f1 commit 9ffbe9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 9 additions & 3 deletions examples/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions lib/services/tastytrade-http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import axios from "axios"
import qs from 'qs'
import { recursiveDasherizeKeys } from "../utils/json-util"
import _ from 'lodash'
import https from 'https'
import { MinTlsVersion } from "../utils/constants"

const ParamsSerializer = {
serialize: function (queryParams: object) {
Expand All @@ -14,11 +12,9 @@ const ParamsSerializer = {

export default class TastytradeHttpClient{
public readonly session: TastytradeSession
private readonly httpsAgent: https.Agent

constructor(private readonly baseUrl: string) {
this.session = new TastytradeSession()
this.httpsAgent = new https.Agent({ minVersion: MinTlsVersion })
}

private getDefaultHeaders(): any {
Expand Down Expand Up @@ -48,8 +44,7 @@ export default class TastytradeHttpClient{
data: dasherizedData,
headers: mergedHeaders,
params: dasherizedParams,
paramsSerializer: ParamsSerializer,
httpsAgent: this.httpsAgent
paramsSerializer: ParamsSerializer
}, _.isEmpty)

return axios.request(config)
Expand Down

0 comments on commit 9ffbe9f

Please sign in to comment.