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 @@ -82,6 +82,23 @@ export async function load(
}
}

/**
* Loads the data from a CDN and returns an instance of AzureAppConfiguration.
* @param cdnEndpoint The URL to the CDN.
* @param appConfigOptions 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(
cdnEndpoint: string | URL,
appConfigOptions?: AzureAppConfigurationOptions
): Promise<AzureAppConfiguration> {
const emptyTokenCredential: TokenCredential = {
getToken: async () => ({ token: "", expiresOnTimestamp: 0 })
};
return await load(cdnEndpoint, emptyTokenCredential, appConfigOptions);
}

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