Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

PharmaLedger-IMI/epi-workspace#930 get network name from environment #19

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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