UNPKG

@coveo/platform-client

Version:

The main goal of this package is to provide an easy to configure and straightforward way of querying Coveo Cloud APIs using JavaScript.

34 lines 1.54 kB
const regionPlaceholder = '{region}'; export var Region; (function (Region) { Region["US"] = "us"; Region["EU"] = "eu"; Region["AU"] = "au"; Region["CA"] = "ca"; })(Region || (Region = {})); export var Environment; (function (Environment) { Environment["dev"] = "dev"; Environment["stg"] = "stg"; Environment["prod"] = "production"; Environment["hipaa"] = "hipaa"; })(Environment || (Environment = {})); const endpointTemplates = { [Environment.dev]: `https://platformdev${regionPlaceholder}.cloud.coveo.com`, [Environment.stg]: `https://platformstg${regionPlaceholder}.cloud.coveo.com`, [Environment.prod]: `https://platform${regionPlaceholder}.cloud.coveo.com`, [Environment.hipaa]: 'https://platformhipaa.cloud.coveo.com', }; const serverlessEndpointTemplates = { [Environment.dev]: `https://apidev${regionPlaceholder}.cloud.coveo.com`, [Environment.stg]: `https://apistg${regionPlaceholder}.cloud.coveo.com`, [Environment.prod]: `https://api${regionPlaceholder}.cloud.coveo.com`, [Environment.hipaa]: 'https://apihipaa.cloud.coveo.com', }; export default (environment = Environment.prod, region = Region.US, isServerlessHost = false) => { const regionSuffix = region === Region.US ? '' : `-${region}`; const matcher = new RegExp(regionPlaceholder, 'g'); const template = isServerlessHost ? serverlessEndpointTemplates[environment] : endpointTemplates[environment]; return template?.replace(matcher, regionSuffix) ?? ''; }; //# sourceMappingURL=Endpoints.js.map