Skip to content

Commit

Permalink
feat!: add a custom base url for sidecase resolves
Browse files Browse the repository at this point in the history
  • Loading branch information
nickybondarenko committed Sep 10, 2024
1 parent 85b8b15 commit 2c1dec4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/sdk/src/FlagResolverClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { SimpleFetch } from './types';
const FLAG_PREFIX = 'flags/';

export class ResolveError extends Error {
constructor(public readonly code: FlagEvaluation.ErrorCode, message: string) {
constructor(
public readonly code: FlagEvaluation.ErrorCode,
message: string,
) {
super(message);
}
}
Expand Down Expand Up @@ -84,6 +87,7 @@ export type FlagResolverClientOptions = {
resolveTimeout: number;
environment: 'client' | 'backend';
region?: 'eu' | 'us';
APIResolveBaseUrl?: string;
};

export class FetchingFlagResolverClient implements FlagResolverClient {
Expand All @@ -103,13 +107,17 @@ export class FetchingFlagResolverClient implements FlagResolverClient {
// todo refactor to move out environment
environment,
region,
APIResolveBaseUrl,
}: FlagResolverClientOptions) {
// TODO think about both resolve and apply request logic for backends
this.fetchImplementation = environment === 'backend' ? fetchImplementation : withRequestLogic(fetchImplementation);
this.clientSecret = clientSecret;
this.sdk = sdk;
this.applyTimeout = applyTimeout;
this.baseUrl = region ? `https://resolver.${region}.confidence.dev/v1` : 'https://resolver.confidence.dev/v1';
this.baseUrl =
APIResolveBaseUrl || region
? `https://resolver.${region}.confidence.dev/v1`
: 'https://resolver.confidence.dev/v1';
this.resolveTimeout = resolveTimeout;
}

Expand Down

0 comments on commit 2c1dec4

Please sign in to comment.