Skip to content
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

export { AzureAppConfiguration } from "./AzureAppConfiguration";
export { Disposable } from "./common/disposable";
export { load } from "./load";
export { load, loadFromCdn } from "./load";
export { KeyFilter, LabelFilter } from "./types";
17 changes: 17 additions & 0 deletions src/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ export async function load(
}
}

/**
* Loads the data from a CDN and returns an instance of AzureAppConfiguration.
* @param endpoint The URL to the CDN.
* @param options Optional parameters.
*/
export async function loadFromCdn(endpoint: URL | string, options?: AzureAppConfigurationOptions): Promise<AzureAppConfiguration>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endpoint

Should this be updated too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird, I remembered I updated this in the commit, will update it again


export async function loadFromCdn(
endpoint: string | URL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it will be too much to call it cdnEndpoint or it's clearer? The reason I'm asking is because we also have the other parameter appConfigOptions. Will that confuse users that it's appconfig endpoint?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with cdnEndpoint. Updated.

appConfigOptions?: AzureAppConfigurationOptions
): Promise<AzureAppConfiguration> {
const emptyTokenCredential: TokenCredential = {
getToken: async () => ({ token: "", expiresOnTimestamp: 0 })
};
return await load(endpoint, emptyTokenCredential, appConfigOptions);
}

function instanceOfTokenCredential(obj: unknown) {
return obj && typeof obj === "object" && "getToken" in obj && typeof obj.getToken === "function";
}
Expand Down
Loading