Skip to content

Commit 07e3e2f

Browse files
committed
Require endpoint and apiKey properties in SDK constructor
Closes T-1149
1 parent 2915a77 commit 07e3e2f

File tree

4 files changed

+5
-29
lines changed

4 files changed

+5
-29
lines changed

src/classes/IntervalClient.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ initAsyncLocalStorage()
8282

8383
export { actionLocalStorage, pageLocalStorage }
8484

85-
export const DEFAULT_WEBSOCKET_ENDPOINT = 'wss://interval.com/websocket'
86-
8785
export function getHttpEndpoint(wsEndpoint: string) {
8886
const url = new URL(wsEndpoint)
8987
url.protocol = url.protocol.replace('ws', 'http')
@@ -103,7 +101,7 @@ interface SetupConfig {
103101
export default class IntervalClient {
104102
#interval: Interval
105103
#apiKey: string | undefined
106-
#endpoint: string = DEFAULT_WEBSOCKET_ENDPOINT
104+
#endpoint: string
107105
#httpEndpoint: string
108106
#logger: Logger
109107
#completeHttpRequestDelayMs: number = 3000
@@ -140,10 +138,7 @@ export default class IntervalClient {
140138
this.#apiKey = config.apiKey
141139
this.#logger = new Logger(config.logLevel)
142140
this.#config = config
143-
144-
if (config.endpoint) {
145-
this.#endpoint = config.endpoint
146-
}
141+
this.#endpoint = config.endpoint
147142

148143
if (config.retryIntervalMs && config.retryIntervalMs > 0) {
149144
this.#retryIntervalMs = config.retryIntervalMs

src/examples/basic/ghostHost.ts

-15
This file was deleted.

src/examples/basic/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import type { EventualMetaItem } from '../../components/displayMetadata'
1616
import * as table_actions from './table'
1717
import * as grid_actions from './grid'
1818
import unauthorized from './unauthorized'
19-
import './ghostHost'
2019
import { generateS3Urls } from '../utils/upload'
2120
import fs from 'fs'
2221
import fakeUsers from '../utils/fakeUsers'

src/index.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import type {
3131
} from './types'
3232
import IntervalError from './classes/IntervalError'
3333
import IntervalClient, {
34-
DEFAULT_WEBSOCKET_ENDPOINT,
3534
getHttpEndpoint,
3635
actionLocalStorage,
3736
pageLocalStorage,
@@ -51,14 +50,14 @@ export type {
5150
}
5251

5352
export interface InternalConfig {
54-
apiKey?: string
53+
apiKey: string
54+
endpoint: string
5555
routes?: IntervalRouteDefinitions
5656
routesDirectory?: string
5757
// TODO: Mark as deprecated soon, remove soon afterward
5858
actions?: Record<string, IntervalActionDefinition>
5959
// TODO: Mark as deprecated soon, remove soon afterward
6060
groups?: Record<string, Page>
61-
endpoint?: string
6261
logLevel?: LogLevel
6362
retryIntervalMs?: number
6463
retryChunkIntervalMs?: number
@@ -176,9 +175,7 @@ export default class Interval {
176175
this.#apiKey = config.apiKey
177176
this.#logger = new Logger(config.logLevel)
178177

179-
this.#httpEndpoint = getHttpEndpoint(
180-
config.endpoint ?? DEFAULT_WEBSOCKET_ENDPOINT
181-
)
178+
this.#httpEndpoint = getHttpEndpoint(config.endpoint)
182179

183180
this.routes = new Routes(
184181
this,

0 commit comments

Comments
 (0)