Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit 8a26dd7

Browse files
committed
Use globalThis to simplify default options
1 parent 783ef7d commit 8a26dd7

2 files changed

Lines changed: 9 additions & 16 deletions

File tree

docs/classes/Seam.md

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/seam-connect/client.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,11 @@ export interface SeamClientOptions {
3838
export const getSeamClientOptionsWithDefaults = (
3939
apiKeyOrOptions?: string | SeamClientOptions
4040
): SeamClientOptions => {
41-
const defaultEndpoint = "https://connect.getseam.com"
42-
let seamClientDefaults: SeamClientOptions = { endpoint: defaultEndpoint }
43-
try {
44-
// try to get defaults from environment (for server-side use)
45-
seamClientDefaults = {
46-
apiKey: process?.env?.SEAM_API_KEY,
47-
endpoint: process?.env?.SEAM_API_URL ?? defaultEndpoint,
48-
workspaceId: process?.env?.SEAM_WORKSPACE_ID,
49-
}
50-
} catch (error) {
51-
// we are in a browser, so use the apiKeyOrOptions
52-
// do nothing
41+
const seamClientDefaults = {
42+
apiKey: globalThis?.process?.env?.SEAM_API_KEY ?? undefined,
43+
endpoint:
44+
globalThis?.process?.env?.SEAM_API_URL ?? "https://connect.getseam.com",
45+
workspaceId: globalThis?.process?.env?.SEAM_WORKSPACE_ID ?? undefined,
5346
}
5447
if (typeof apiKeyOrOptions === "string") {
5548
// for both browser and server, if apiKeyOrOptions is a string, use it as the apiKey, and merge with defaults

0 commit comments

Comments
 (0)