Skip to content

Commit 02eb711

Browse files
committed
Fix wrapper
1 parent 9b79dd2 commit 02eb711

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

src/IcePanelClient.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import type { BaseClientOptions } from "./BaseClient.js"
33
import * as core from "./core/index.js"
44
import type { IcePanelAPIVersion } from "./consts.js"
55

6-
export interface IcePanelOptions {
6+
export interface IcePanelOptions extends Omit<BaseClientOptions, 'apiKeyAuth' | 'bearerAuth'> {
77
apiVersion: IcePanelAPIVersion
8+
apiKey?: core.Supplier<string>
9+
token?: core.Supplier<string>
810
}
911

1012
export class IcePanelClient extends Client {
11-
constructor(options: IcePanelOptions & BaseClientOptions) {
13+
constructor(options: IcePanelOptions) {
1214
const updatedOptions: BaseClientOptions = {
13-
...options
15+
...options,
16+
apiKeyAuth: undefined,
17+
bearerAuth: undefined
1418
}
1519

1620
updatedOptions.baseUrl = async () => {
@@ -21,6 +25,18 @@ export class IcePanelClient extends Client {
2125
return `https://api.icepanel.io/${options.apiVersion}`
2226
}
2327

28+
if (options.apiKey) {
29+
updatedOptions.apiKeyAuth = {
30+
key: options.apiKey
31+
}
32+
}
33+
34+
if (options.token) {
35+
updatedOptions.bearerAuth = {
36+
token: options.token
37+
}
38+
}
39+
2440
super(updatedOptions)
2541
}
26-
}
42+
}

0 commit comments

Comments
 (0)