const ApiKeyPrefixToEnvironmentSuffix: { [key: string]: string } = { dev: '-dev', staging: '-staging', sandbox: '-sandbox', prod: '', } export const getBaseUrl = (publicApiKey: string) => { const [apiKeyPrefix] = publicApiKey.split('_') const environmentSuffix = ApiKeyPrefixToEnvironmentSuffix[apiKeyPrefix] if (environmentSuffix === undefined) { throw new Error( `Not environment found publicApiKey: ${publicApiKey}, apiKeyPrefix: ${apiKeyPrefix}, environmentSuffix: ${environmentSuffix}` ) } return 'https://api_ENVIRONMENT_.y.uno/v1'.replace( '_ENVIRONMENT_', environmentSuffix ) }