Skip to content

Commit

Permalink
Update parseOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Sep 21, 2023
1 parent 93ba264 commit c2ad768
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/lib/seam/connect/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ export class SeamHttp {
#legacy: boolean

constructor(apiKeyOrOptions: string | SeamHttpOptions) {
const options = parseOptions(
typeof apiKeyOrOptions === 'string'
? { apiKey: apiKeyOrOptions }
: apiKeyOrOptions,
)

const options = parseOptions(apiKeyOrOptions)
this.#legacy = options.enableLegacyMethodBehaivor

// TODO: axiosRetry? Allow options to configure this if so
Expand Down Expand Up @@ -78,7 +73,14 @@ export class SeamHttp {
}
}

const parseOptions = (options: SeamHttpOptions): Required<SeamHttpOptions> => {
const parseOptions = (
apiKeyOrOptions: string | SeamHttpOptions,
): Required<SeamHttpOptions> => {
const options =
typeof apiKeyOrOptions === 'string'
? { apiKey: apiKeyOrOptions }
: apiKeyOrOptions

const endpoint =
options.endpoint ??
globalThis.process?.env?.['SEAM_ENDPOINT'] ??
Expand Down

0 comments on commit c2ad768

Please sign in to comment.