vtlab-generic-functions 1.0.16 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/config/index.js CHANGED
@@ -16,19 +16,27 @@ const getObjectByString = (obj, key) => {
16
16
  // Cache object
17
17
  let cache = {};
18
18
 
19
- const getConfigValuesFromS3Bucket = async (configKey = null, ifValuesFromRoot = null) => {
19
+ const getConfigValuesFromS3Bucket = async (configKey = null, env = null) => {
20
20
  const { NODE_ENV, TOOK_SECRETS_BUCKET, TOOK_SECRETS_DEVELOP, TOOK_SECRETS_PRODUCTION } = process.env;
21
21
  let defaultEnvironment = NODE_ENV;
22
+ let valuesFromRoot;
23
+ if(env==="rds" || env==="notificationEmailForDebug") {
24
+ valuesFromRoot = env;
25
+ env = null;
26
+ }
22
27
  const availableEnvironments = ['production', 'develop', 'staging', 'uat', 'demo', 'test', 'testing'];
23
28
  if (!defaultEnvironment || !availableEnvironments.includes(defaultEnvironment)) {
24
29
  defaultEnvironment = 'develop';
25
30
  }
26
- const effectiveEnvironment = ifValuesFromRoot || defaultEnvironment;
31
+ let effectiveEnvironment = env || defaultEnvironment;
27
32
  let secretName = TOOK_SECRETS_DEVELOP;
28
33
  if (effectiveEnvironment === 'production') {
29
34
  secretName = TOOK_SECRETS_PRODUCTION;
30
35
  }
31
36
  const secretsBucketName = TOOK_SECRETS_BUCKET;
37
+ if(valuesFromRoot) {
38
+ effectiveEnvironment = valuesFromRoot;
39
+ }
32
40
 
33
41
  // Check cache first
34
42
  if (cache[effectiveEnvironment] && (!configKey || cache[effectiveEnvironment][configKey])) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vtlab-generic-functions",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "scripts": {
5
5
  "test": "jest"
6
6
  },
package/rds/index.js CHANGED
@@ -9,7 +9,7 @@ const {getValueOrNull} = require('../utils/index');
9
9
  */
10
10
  const connectMyRDS = async (databaseName) => {
11
11
  try {
12
- const dbParams = await config.get(`rds.${databaseName}`);
12
+ const dbParams = await config.get(databaseName, 'rds');
13
13
 
14
14
  if (!dbParams) {
15
15
  throw new Error('Database name is not valid in the Secret Manager');