diff --git a/packages/common/env.js b/packages/common/env.js new file mode 100644 index 0000000000000000000000000000000000000000..a960d88139dc87c4089375c4468ad31fe4d89dcf --- /dev/null +++ b/packages/common/env.js @@ -0,0 +1,36 @@ +var config; + +switch(process.env.BUILD) { + case "development": + config = { + apiBaseUrl: 'https://mw-dev.tugraz.at', + apiUrlPrefix: '', + keyCloakClientId: 'auth-dev-mw-frontend', + }; + + break; + case "production": + config = { + apiBaseUrl: 'https://mw.tugraz.at', + apiUrlPrefix: '', + keyCloakClientId: 'auth-prod-mw-frontend', + }; + break; + case "demo": + config = { + apiBaseUrl: 'https://api-demo.tugraz.at', + apiUrlPrefix: '', + keyCloakClientId: 'auth-dev-mw-frontend', + }; + break; + case "local": + default: + config = { + apiBaseUrl: 'http://127.0.0.1:8000', + apiUrlPrefix: '', + keyCloakClientId: 'auth-dev-mw-frontend-local', + }; +} + + +export default config; diff --git a/packages/common/utils.js b/packages/common/utils.js index 10ae38c977e01ba00452b2d2b3465f20ca5e7d7c..002d0538bad6bdd1c706f3ddf0b384544cff7404 100644 --- a/packages/common/utils.js +++ b/packages/common/utils.js @@ -1,3 +1,5 @@ +import env from './env.js'; + export default { /** * Parses a link header @@ -29,6 +31,20 @@ export default { return links; }, + /** + * Reads a setting + * + * @param key + * @returns {*} + */ + setting: (key) => { + return env[key]; + }, + + getAPiUrl: (path = "", withPrefix = true) => { + return env.apiBaseUrl + (withPrefix ? vars.apiUrlPrefix : "") + path; + }, + /** * Parses the base url from an url *