Skip to content

Commit

Permalink
PharmaLedger-IMI/epi-workspace#930 get network name from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
luputeodor2 committed Oct 6, 2022
1 parent bb7ba38 commit 6c8dec3
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions code/scripts/services/SettingsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,34 @@ export default class SettingsService {

}

readSettingFromEnvironment(name, callback) {
require("opendsu").loadApi("config").getEnv(name, callback);
}

initDefaultValues() {
Object.keys(DEFAULT_VALUES).forEach(prop => {
this.readSetting(prop, (err, result) => {
if (err) {
this.writeSetting(prop, DEFAULT_VALUES[prop], (err, record) => {
if (err) {
console.log("Error in settings service constructor. Could not insert record for: ", prop, DEFAULT_VALUES[prop]);
}
})
}
})
this.readSettingFromEnvironment("epiDomain", (err, res) => {
if (err) {
console.log("Unable to find key epiDomain in environment file.", err);
writeDefaultValues.call(this);
return;
}
DEFAULT_VALUES.networkName = res;
writeDefaultValues.call(this);
})

function writeDefaultValues() {
Object.keys(DEFAULT_VALUES).forEach(prop => {
this.readSetting(prop, (err, result) => {
if (err) {
this.writeSetting(prop, DEFAULT_VALUES[prop], (err, record) => {
if (err) {
console.log("Error in settings service constructor. Could not insert record for: ", prop, DEFAULT_VALUES[prop]);
}
})
}
})
})
}
}

readSetting(property, callback) {
Expand Down

0 comments on commit 6c8dec3

Please # to comment.