MCPcopy Create free account
hub / github.com/CloudBoost/cloudboost / initSettingsVariable

Function initSettingsVariable

database-connect/keyService.js:60–91  ·  view source on GitHub ↗
(dbc)

Source from the content-addressed store, hash-verified

58 },
59
60 async initSettingsVariable(dbc) {
61 const deferred = q.defer();
62
63 try {
64 const collection = dbc.db(config.globalDb).collection(config.globalSettings);
65 const docs = await collection.find({}).toArray();
66 if (docs.length) {
67 const [doc] = docs;
68 if (doc.secureKey && doc.clusterKey && doc.myURL) {
69 deferred.resolve(doc);
70 } else {
71 // Update the found configuration.
72 await _saveSettings({ collection, doc });
73 const newDoc = await this.getSettingsVariables(dbc);
74 deferred.resolve(newDoc);
75 }
76 } else {
77 // Update the found configuration.
78 await _saveSettings({ collection });
79 const newDoc = await this.getSettingsVariables(dbc);
80 deferred.resolve(newDoc);
81 }
82 } catch (error) {
83 winston.error({
84 error: String(error),
85 stack: new Error().stack,
86 });
87 deferred.reject(error);
88 }
89
90 return deferred.promise;
91 },
92
93 getMyUrl() {
94 const deferred = q.defer();

Callers

nothing calls this directly

Calls 2

_saveSettingsFunction · 0.85
findMethod · 0.80

Tested by

no test coverage detected