diff --git a/package-lock.json b/package-lock.json index 0a0abba6..eb8d64b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "monday-sdk-js", - "version": "0.4.2", + "version": "0.4.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "monday-sdk-js", - "version": "0.4.2", + "version": "0.4.3", "license": "MIT", "dependencies": { "node-fetch": "^2.6.0" diff --git a/package.json b/package.json index cd1eb2a8..7c8203d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "monday-sdk-js", - "version": "0.4.2", + "version": "0.4.3", "private": false, "repository": "https://github.com/mondaycom/monday-sdk-js", "main": "src/index.js", diff --git a/src/constants.js b/src/constants.js index 2c5c3971..87c97b2b 100644 --- a/src/constants.js +++ b/src/constants.js @@ -1,12 +1,18 @@ const { isBrowser } = require("./helpers"); const isNodeDevEnv = !isBrowser && process.env.NODE_ENV === "development"; +const getEnvOrDefault = (key, defaultVal) => { + return isNodeDevEnv && typeof process.env[key] !== "undefined" ? process.env[key] : defaultVal; +}; + +const MONDAY_PROTOCOL = getEnvOrDefault("MONDAY_COM_PROTOCOL", "https"); +const MONDAY_DOMAIN = getEnvOrDefault("MONDAY_COM_DOMAIN", "monday.com"); +const MONDAY_SUBDOMAIN_API = getEnvOrDefault("MONDAY_SUBDOMAIN_API", "api."); +const MONDAY_OAUTH_SUBDOMAIN = getEnvOrDefault(MONDAY_SUBDOMAIN_API, "auth."); -const MONDAY_PROTOCOL = (isNodeDevEnv && process.env.MONDAY_COM_PROTOCOL) || "https"; -const MONDAY_DOMAIN = (isNodeDevEnv && process.env.MONDAY_COM_DOMAIN) || "monday.com"; -const MONDAY_API_URL = `${MONDAY_PROTOCOL}://api.${MONDAY_DOMAIN}/v2`; -const MONDAY_OAUTH_URL = `${MONDAY_PROTOCOL}://auth.${MONDAY_DOMAIN}/oauth2/authorize`; -const MONDAY_OAUTH_TOKEN_URL = `${MONDAY_PROTOCOL}://auth.${MONDAY_DOMAIN}/oauth2/token`; +const MONDAY_API_URL = `${MONDAY_PROTOCOL}://${MONDAY_SUBDOMAIN_API}${MONDAY_DOMAIN}/v2`; +const MONDAY_OAUTH_URL = `${MONDAY_PROTOCOL}://${MONDAY_OAUTH_SUBDOMAIN}${MONDAY_DOMAIN}/oauth2/authorize`; +const MONDAY_OAUTH_TOKEN_URL = `${MONDAY_PROTOCOL}://${MONDAY_OAUTH_SUBDOMAIN}${MONDAY_DOMAIN}/oauth2/token`; module.exports = { MONDAY_DOMAIN,