not-node 6.2.10 → 6.2.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.2.10",
3
+ "version": "6.2.12",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -59,15 +59,14 @@
59
59
  "mongoose": "*",
60
60
  "mongoose-validator": "*",
61
61
  "nconf": "*",
62
- "not-config": "^0.1.5",
63
- "not-error": "^0.2.5",
62
+ "not-config": "*",
63
+ "not-error": "*",
64
64
  "not-filter": "*",
65
- "not-inform": "^0.0.28",
66
65
  "not-locale": "*",
67
- "not-log": "^0.0.20",
68
- "not-monitor": "^0.0.13",
69
- "not-path": "^1.0.4",
70
- "not-validation": "^0.0.8",
66
+ "not-log": "*",
67
+ "not-monitor": "*",
68
+ "not-path": "*",
69
+ "not-validation": "*",
71
70
  "rate-limiter-flexible": "^2.4.1",
72
71
  "redis": "^4.5.1",
73
72
  "redlock": "^5.0.0-beta.2",
package/src/common.js CHANGED
@@ -205,6 +205,20 @@ module.exports.tryFile = (filePath) => {
205
205
  }
206
206
  };
207
207
 
208
+ /**
209
+ * Trying to parse input to JSON or returns def
210
+ * @param {string} input string to be parsed
211
+ * @param {any} def what to return if parse failed, default undefined
212
+ * @return {Object} JSON
213
+ **/
214
+ module.exports.tryParse = (input, def = undefined) => {
215
+ try {
216
+ return JSON.parse(input);
217
+ } catch (e) {
218
+ return def;
219
+ }
220
+ };
221
+
208
222
  /**
209
223
  * Generates paths object for module/index.js files based on content and relative
210
224
  * path
@@ -21,6 +21,7 @@ module.exports = class InitApp {
21
21
 
22
22
  static async setAppEnvs({ config, options, master, emit }) {
23
23
  await emit("app.setEnv.pre", { config, options, master });
24
+ master.setEnv("validationEnv", options.validationEnv);
24
25
  master.setEnv("hostname", config.get("hostname"));
25
26
  master.setEnv("server", `https://` + config.get("host"));
26
27
  master.setEnv("appPath", config.get("appPath"));
@@ -6,8 +6,15 @@ module.exports = class InitDBRedis {
6
6
  log.info("Setting up redis connection...");
7
7
  const redis = require("redis");
8
8
  const redisClient = redis.createClient(conf);
9
+ await redisClient.connect();
9
10
  InitDBRedis.bindClientEvents({ master, redisClient });
10
11
  master.setEnv(`db.${alias}`, redisClient);
12
+ const status = redisClient.isOpen;
13
+ if (status) {
14
+ log.info(`Redis connection is opened`);
15
+ } else {
16
+ log.error(`Redis connection isn't opened`);
17
+ }
11
18
  }
12
19
 
13
20
  async run({ config, options, master, conf, alias, emit }) {
@@ -6,14 +6,14 @@ const notEnv = require("../env");
6
6
  function extractValidationEnvGetter(options) {
7
7
  if (
8
8
  options &&
9
- objHas(options, "getValidationEnv") &&
10
- isFunc(options.getValidationEnv)
9
+ objHas(options, "validationEnv") &&
10
+ isFunc(options.validationEnv)
11
11
  ) {
12
- return options.getValidationEnv;
12
+ return options.validationEnv;
13
13
  } else {
14
- const globalGetValidationEnv = notEnv.getEnv("getValidationEnv");
15
- if (globalGetValidationEnv && isFunc(globalGetValidationEnv)) {
16
- return globalGetValidationEnv;
14
+ const globalValidationEnvGetter = notEnv.getEnv("validationEnv");
15
+ if (globalValidationEnvGetter && isFunc(globalValidationEnvGetter)) {
16
+ return globalValidationEnvGetter;
17
17
  } else {
18
18
  //should return at least empty object
19
19
  return () => {