@blizzard-api/core
Version:
The core helpers used by all @blizzard-api/* packages.
58 lines (46 loc) • 1.18 kB
JavaScript
//#region src/blizzard-api.ts
const endpoints = {
cn: {
defaultLocale: "zh_CN",
hostname: "https://gateway.battlenet.com.cn"
},
eu: {
defaultLocale: "en_GB",
hostname: "https://eu.api.blizzard.com"
},
kr: {
defaultLocale: "ko_KR",
hostname: "https://kr.api.blizzard.com"
},
tw: {
defaultLocale: "zh_TW",
hostname: "https://tw.api.blizzard.com"
},
us: {
defaultLocale: "en_US",
hostname: "https://us.api.blizzard.com"
}
};
/**
* Get the Blizzard API configuration for a given region.
* @template T The region of the Blizzard API.
* @param origin The region of the Blizzard API.
* @param locale The locale of the Blizzard API.
* @returns The Blizzard API configuration for the given region.
* @example
* const api = getBlizzardApi('us', 'en_US');
* console.log(api.hostname); // 'https://us.api.blizzard.com'
* console.log(api.locale); // 'en_US'
* console.log(api.origin); // 'us'
*/
function getBlizzardApi(origin, locale) {
const endpoint = endpoints[origin];
return {
hostname: endpoint.hostname,
locale: locale ?? endpoint.defaultLocale,
origin
};
}
//#endregion
export { getBlizzardApi };
//# sourceMappingURL=index.js.map