|
1 | 1 | import type { EvaluationResponse, HyphenEvaluationContext, HyphenProviderOptions, TelemetryPayload } from './types';
|
2 |
| -import { horizon } from './config'; |
3 | 2 | import type { Logger } from '@openfeature/server-sdk';
|
4 | 3 | import { CacheClient } from './cacheClient';
|
| 4 | +import { buildDefaultHorizonUrl } from './utils'; |
5 | 5 |
|
6 | 6 | export class HyphenClient {
|
7 | 7 | private readonly publicKey: string;
|
8 |
| - private readonly horizonServerUrls: string[]; |
| 8 | + private readonly horizonUrls: string[]; |
| 9 | + private readonly defaultHorizonUrl: string; |
9 | 10 | private cache: CacheClient;
|
10 | 11 |
|
11 | 12 | constructor(publicKey: string, options: HyphenProviderOptions) {
|
12 | 13 | this.publicKey = publicKey;
|
13 |
| - this.horizonServerUrls = [...(options.horizonServerUrls || []), horizon.url]; |
| 14 | + this.defaultHorizonUrl = buildDefaultHorizonUrl(publicKey); |
| 15 | + this.horizonUrls = [...(options.horizonServerUrls || []), this.defaultHorizonUrl]; |
14 | 16 | this.cache = new CacheClient(options.cache);
|
15 | 17 | }
|
16 | 18 |
|
17 | 19 | private async tryUrls(urlPath: string, payload: unknown, logger?: Logger): Promise<Response> {
|
18 | 20 | let lastError: unknown;
|
19 | 21 |
|
20 |
| - for (let url of this.horizonServerUrls) { |
| 22 | + for (let url of this.horizonUrls) { |
21 | 23 | try {
|
22 | 24 | const baseUrl = new URL(url);
|
23 | 25 | const basePath = baseUrl.pathname.replace(/\/$/, '');
|
|
0 commit comments