Skip to content

Commit

Permalink
Require endpoint and apiKey properties in SDK constructor
Browse files Browse the repository at this point in the history
Closes T-1149
  • Loading branch information
jacobmischka committed Nov 15, 2023
1 parent 2915a77 commit 07e3e2f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 29 deletions.
9 changes: 2 additions & 7 deletions src/classes/IntervalClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ initAsyncLocalStorage()

export { actionLocalStorage, pageLocalStorage }

export const DEFAULT_WEBSOCKET_ENDPOINT = 'wss://interval.com/websocket'

export function getHttpEndpoint(wsEndpoint: string) {
const url = new URL(wsEndpoint)
url.protocol = url.protocol.replace('ws', 'http')
Expand All @@ -103,7 +101,7 @@ interface SetupConfig {
export default class IntervalClient {
#interval: Interval
#apiKey: string | undefined
#endpoint: string = DEFAULT_WEBSOCKET_ENDPOINT
#endpoint: string
#httpEndpoint: string
#logger: Logger
#completeHttpRequestDelayMs: number = 3000
Expand Down Expand Up @@ -140,10 +138,7 @@ export default class IntervalClient {
this.#apiKey = config.apiKey
this.#logger = new Logger(config.logLevel)
this.#config = config

if (config.endpoint) {
this.#endpoint = config.endpoint
}
this.#endpoint = config.endpoint

if (config.retryIntervalMs && config.retryIntervalMs > 0) {
this.#retryIntervalMs = config.retryIntervalMs
Expand Down
15 changes: 0 additions & 15 deletions src/examples/basic/ghostHost.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/examples/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type { EventualMetaItem } from '../../components/displayMetadata'
import * as table_actions from './table'
import * as grid_actions from './grid'
import unauthorized from './unauthorized'
import './ghostHost'
import { generateS3Urls } from '../utils/upload'
import fs from 'fs'
import fakeUsers from '../utils/fakeUsers'
Expand Down
9 changes: 3 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import type {
} from './types'
import IntervalError from './classes/IntervalError'
import IntervalClient, {
DEFAULT_WEBSOCKET_ENDPOINT,
getHttpEndpoint,
actionLocalStorage,
pageLocalStorage,
Expand All @@ -51,14 +50,14 @@ export type {
}

export interface InternalConfig {
apiKey?: string
apiKey: string
endpoint: string
routes?: IntervalRouteDefinitions
routesDirectory?: string
// TODO: Mark as deprecated soon, remove soon afterward
actions?: Record<string, IntervalActionDefinition>
// TODO: Mark as deprecated soon, remove soon afterward
groups?: Record<string, Page>
endpoint?: string
logLevel?: LogLevel
retryIntervalMs?: number
retryChunkIntervalMs?: number
Expand Down Expand Up @@ -176,9 +175,7 @@ export default class Interval {
this.#apiKey = config.apiKey
this.#logger = new Logger(config.logLevel)

this.#httpEndpoint = getHttpEndpoint(
config.endpoint ?? DEFAULT_WEBSOCKET_ENDPOINT
)
this.#httpEndpoint = getHttpEndpoint(config.endpoint)

this.routes = new Routes(
this,
Expand Down

0 comments on commit 07e3e2f

Please sign in to comment.