Skip to content

Commit 9c0b9fd

Browse files
author
Georgii Petrov
committed
[utils] deepMergeObjecs() added
1 parent 936b5a4 commit 9c0b9fd

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

Common/config/default.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
"connectionlimit": 10,
178178
"max_allowed_packet": 1048575,
179179
"pgPoolExtraOptions": {
180-
"idleTimeoutMillis": 3000,
180+
"idleTimeoutMillis": 30000,
181181
"maxLifetimeSeconds ": 60000,
182182
"statement_timeout ": 60000,
183183
"query_timeout ": 60000,
@@ -202,7 +202,7 @@
202202
"trustServerCertificate": true
203203
},
204204
"pool": {
205-
"idleTimeoutMillis": 3000
205+
"idleTimeoutMillis": 30000
206206
}
207207
}
208208
},

Common/sources/utils.js

+29
Original file line numberDiff line numberDiff line change
@@ -1111,3 +1111,32 @@ exports.checksumFile = function(hashName, path) {
11111111
stream.on('end', () => resolve(hash.digest('hex')));
11121112
});
11131113
};
1114+
1115+
function isObject(item) {
1116+
return (item && typeof item === 'object' && !Array.isArray(item));
1117+
}
1118+
1119+
function deepMergeObjects(target, ...sources) {
1120+
if (!sources.length) {
1121+
return target;
1122+
}
1123+
1124+
const source = sources.shift();
1125+
if (isObject(target) && isObject(source)) {
1126+
for (const key in source) {
1127+
if (isObject(source[key])) {
1128+
if (!target[key]) {
1129+
Object.assign(target, { [key]: {} });
1130+
}
1131+
1132+
deepMergeObjects(target[key], source[key]);
1133+
} else {
1134+
Object.assign(target, { [key]: source[key] });
1135+
}
1136+
}
1137+
}
1138+
1139+
return deepMergeObjects(target, ...sources);
1140+
}
1141+
exports.isObject = isObject;
1142+
exports.deepMergeObjects = deepMergeObjects;

DocService/sources/databaseConnectors/damengConnector.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
3030
*
3131
*/
32-
32+
// git actions trigger
3333
'use strict';
3434

3535
const connectorUtilities = require('./connectorUtilities');

DocService/sources/databaseConnectors/mssqlConnector.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,7 @@ const connectionConfiguration = {
5454
}
5555
};
5656
const additionalOptions = configSql.get('msSqlExtraOptions');
57-
58-
const mergedObjects = {};
59-
for (const option in additionalOptions) {
60-
if (connectionConfiguration.hasOwnProperty(option) && typeof connectionConfiguration[option] === 'object') {
61-
mergedObjects[option] = Object.assign({}, connectionConfiguration[option], additionalOptions[option]);
62-
} else {
63-
mergedObjects[option] = additionalOptions[option];
64-
}
65-
}
66-
67-
const configuration = Object.assign({}, connectionConfiguration, mergedObjects);
57+
const configuration = utils.deepMergeObjects({}, connectionConfiguration, additionalOptions);
6858

6959
const placeholderPrefix = 'ph_';
7060

0 commit comments

Comments
 (0)