Skip to content

Commit

Permalink
Refactor Configuration validation to use assertParamExists for apiUrl…
Browse files Browse the repository at this point in the history
… check
  • Loading branch information
Waheedsys committed Oct 2, 2024
1 parent c4a69b2 commit efb2400
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 0 additions & 3 deletions client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ 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;
Expand Down
7 changes: 3 additions & 4 deletions configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,9 @@ export class Configuration {
* @throws {FgaValidationError}
*/
public isValid(): boolean {
if (!this.apiUrl) {
assertParamExists("Configuration", "apiScheme", this.apiScheme);
assertParamExists("Configuration", "apiHost", this.apiHost);
}
if (!this.apiUrl && !this.apiScheme && !this.apiHost) {
assertParamExists("Configuration", "apiUrl", this.apiUrl);
}

if (!isWellFormedUriString(this.getBasePath())) {
throw new FgaValidationError(
Expand Down

0 comments on commit efb2400

Please sign in to comment.