From c4a69b22730a22b057578ccdaaa8d581abc156e6 Mon Sep 17 00:00:00 2001 From: syed waheed Date: Wed, 2 Oct 2024 00:30:56 +0530 Subject: [PATCH] Update client.ts Modified the OpenFgaClient constructor to throw a FgaRequiredParamError with a clear message when the apiUrl parameter is not provided. --- client.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client.ts b/client.ts index 0e00738..fcc243e 100644 --- a/client.ts +++ b/client.ts @@ -53,7 +53,7 @@ import { generateRandomIdWithNonUniqueFallback, setHeaderIfNotSet, } from "./utils"; -import { isWellFormedUlidString } from "./validation"; +import { assertParamExists, isWellFormedUlidString } from "./validation"; export type UserClientConfigurationParams = UserConfigurationParams & { storeId?: string; @@ -210,9 +210,10 @@ export class OpenFgaClient extends BaseAPI { } else { this.configuration = new ClientConfiguration(configuration); } + const { apiUrl } = this.configuration; + assertParamExists("OpenFgaClient", "apiUrl", apiUrl); + this.configuration.isValid(); - - this.api = new OpenFgaApi(this.configuration, axios); this.storeId = configuration.storeId; this.authorizationModelId = configuration.authorizationModelId;