@mimik/rediser 1.3.1 → 1.4.6

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/.eslintrc CHANGED
@@ -1,17 +1,29 @@
1
- // Use this file as a starting point for your project's .eslintrc.
2
- // Copy this file, and add rule overrides as needed.
3
1
  {
2
+ "plugins": [
3
+ "@mimik/document-env",
4
+ "@mimik/dependencies"
5
+ ],
4
6
  "env": {
5
7
  "node": true
6
8
  },
9
+ "parserOptions": {
10
+ "ecmaVersion": 2020
11
+ },
7
12
  "extends": "airbnb",
8
13
  "rules": {
14
+ "import/no-extraneous-dependencies": ["error", {"devDependencies": true}],
9
15
  "brace-style": [1, "stroustrup", {"allowSingleLine": true}],
10
16
  "no-confusing-arrow": [0], // arrow isnt confusing
11
17
  "max-len": [1, 180, { "ignoreComments": true }],
12
18
  "linebreak-style": 0,
13
19
  "quotes": [1, "single"],
14
- "semi": [1, "always"]
20
+ "semi": [1, "always"],
21
+ "no-process-env": ["error"],
22
+ "@mimik/document-env/validate-document-env": 2,
23
+ "@mimik/dependencies/case-sensitive": 2,
24
+ "@mimik/dependencies/no-cycles": 2,
25
+ "@mimik/dependencies/no-unresolved": 2,
26
+ "@mimik/dependencies/require-json-ext": 2
15
27
  },
16
28
  "settings":{
17
29
  "react": {
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npm run commit-ready
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npm run test
package/Gulpfile.js CHANGED
@@ -16,14 +16,13 @@ const files = [
16
16
  const createDocs = (done) => {
17
17
  jsdoc2md.render({ files: 'index.js' })
18
18
  .then((output) => fs.writeFileSync('README.md', output))
19
- .catch((err) => log.error('docs creation failed:', err.message));
20
- return done();
19
+ .catch((err) => log.error('docs creation failed:', err.message))
20
+ .finally(() => done());
21
21
  };
22
22
 
23
23
  const lint = () => gulp.src(files)
24
24
  .pipe(eslint({}))
25
- .pipe(eslint.format())
26
- .pipe(eslint.failOnError());
25
+ .pipe(eslint.format());
27
26
 
28
27
  const add = () => gulp.src('README.md')
29
28
  .pipe(git.add({ quiet: true }));
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const logger = require('@mimik/sumologic-winston-logger');
2
+ const { isProd, MASK } = require('@mimik/lib-filters');
2
3
  const redis = require('redis');
3
4
  const Promise = require('bluebird');
4
5
  /**
@@ -9,8 +10,8 @@ const Promise = require('bluebird');
9
10
 
10
11
  Promise.promisifyAll(redis.RedisClient.prototype);
11
12
 
12
- const correlationId = 'cache-start';
13
13
  const type = 'redis';
14
+ const correlationId = `${type}-cache-start@0/${new Date().toISOString()}`;
14
15
 
15
16
  const VALIDATION_CHECK = 100; // in ms
16
17
  const CONNECTED = 1;
@@ -20,6 +21,7 @@ let display = true;
20
21
  let state = DISCONNECTED;
21
22
 
22
23
  module.exports = (set, config) => {
24
+ const { redisSettings } = config;
23
25
  /**
24
26
  * Database initialization.
25
27
  *
@@ -35,9 +37,17 @@ module.exports = (set, config) => {
35
37
  display = false;
36
38
  return null;
37
39
  }
38
- if (display) logger.info('creating a cache connection', { type, settings: config.redisSettings }, correlationId);
40
+ if (display) {
41
+ if (isProd(config.nodeEnvironment)) {
42
+ const redisSettingsClone = { ...redisSettings };
43
+
44
+ if (redisSettings.password) redisSettingsClone.url = `${redisSettings.url.split('=')[0]}=${MASK}`;
45
+ logger.info('creating a cache connection', { type, settings: redisSettingsClone }, correlationId);
46
+ }
47
+ else logger.info('creating a cache connection', { type, settings: redisSettings }, correlationId);
48
+ }
39
49
  display = false;
40
- const client = redis.createClient(config.redisSettings.url, config.redisSettings.options);
50
+ const client = redis.createClient(redisSettings.url, redisSettings.options);
41
51
 
42
52
  client.on('error', (err) => {
43
53
  state = err;
@@ -74,7 +84,7 @@ module.exports = (set, config) => {
74
84
  const interval = setInterval(() => {
75
85
  if (state !== CONNECTED) {
76
86
  logger.error('fatal error: Timeout in connecting to database', {
77
- type, error: state, timeout: config.redisSettings.connectTimeout,
87
+ type, error: state, timeout: redisSettings.connectTimeout,
78
88
  }, correlationId);
79
89
  logger.flushAndExit(1);
80
90
  }
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@mimik/rediser",
3
- "version": "1.3.1",
3
+ "version": "1.4.6",
4
4
  "description": "Helper for setting up redis using redis for mimik microservices",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "lint": "gulp lint",
8
8
  "docs": "gulp docs",
9
9
  "test": "exit 0",
10
- "commit-ready": "gulp docs; gulp lint; npm run test"
10
+ "prepublishOnly": "gulp docs; gulp lint; npm run test",
11
+ "commit-ready": "gulp docs; gulp lint; npm run test",
12
+ "prepare": "husky install"
11
13
  },
12
14
  "husky": {
13
15
  "hooks": {
@@ -19,30 +21,33 @@
19
21
  "mimik",
20
22
  "microservice"
21
23
  ],
22
- "author": "mimik",
24
+ "author": "mimik technology inc <support@mimik.com> (https://developer.mimik.com/)",
23
25
  "license": "Apache-2.0",
24
26
  "repository": {
25
27
  "type": "git",
26
28
  "url": "https://bitbucket.org/mimiktech/rediser"
27
29
  },
28
30
  "dependencies": {
29
- "@mimik/sumologic-winston-logger": "1.3.0",
30
- "bluebird": "3.7.1",
31
- "redis": "2.8.0"
31
+ "@mimik/lib-filters": "^1.4.3",
32
+ "@mimik/sumologic-winston-logger": "^1.6.6",
33
+ "bluebird": "3.7.2",
34
+ "redis": "4.0.1"
32
35
  },
33
36
  "devDependencies": {
34
- "eslint": "6.6.0",
35
- "eslint-config-airbnb": "18.0.1",
36
- "eslint-plugin-import": "2.18.2",
37
- "eslint-plugin-jsx-a11y": "6.2.3",
38
- "eslint-plugin-react": "7.16.0",
39
- "eslint-plugin-react-hooks": "2.2.0",
37
+ "@mimik/eslint-plugin-dependencies": "^2.4.1",
38
+ "@mimik/eslint-plugin-document-env": "^1.0.0",
39
+ "eslint": "8.4.1",
40
+ "eslint-config-airbnb": "18.2.1",
41
+ "eslint-plugin-import": "2.25.3",
42
+ "eslint-plugin-jsx-a11y": "6.5.1",
43
+ "eslint-plugin-react": "7.27.1",
44
+ "eslint-plugin-react-hooks": "4.3.0",
40
45
  "fancy-log": "1.3.3",
41
46
  "gulp": "4.0.2",
42
47
  "gulp-eslint": "6.0.0",
43
- "gulp-git": "2.9.0",
44
- "gulp-rename": "1.4.0",
45
- "husky": "3.0.9",
46
- "jsdoc-to-markdown": "5.0.2"
48
+ "gulp-git": "2.10.1",
49
+ "gulp-rename": "2.0.0",
50
+ "husky": "7.0.4",
51
+ "jsdoc-to-markdown": "7.1.0"
47
52
  }
48
53
  }
package/package.json.bak DELETED
@@ -1,49 +0,0 @@
1
- {
2
- "name": "@mimik/rediser",
3
- "version": "1.3.1",
4
- "description": "Helper for setting up redis using redis for mimik microservices",
5
- "main": "index.js",
6
- "scripts": {
7
- "lint": "gulp lint",
8
- "docs": "gulp docs",
9
- "test": "exit 0",
10
- "prepublishOnly": "gulp docs; gulp lint; npm run test",
11
- "commit-ready": "gulp docs; gulp lint; npm run test"
12
- },
13
- "husky": {
14
- "hooks": {
15
- "pre-commit": "npm run commit-ready",
16
- "pre-push": "npm run test"
17
- }
18
- },
19
- "keywords": [
20
- "mimik",
21
- "microservice"
22
- ],
23
- "author": "mimik",
24
- "license": "Apache-2.0",
25
- "repository": {
26
- "type": "git",
27
- "url": "https://bitbucket.org/mimiktech/rediser"
28
- },
29
- "dependencies": {
30
- "@mimik/sumologic-winston-logger": "1.3.0",
31
- "bluebird": "3.7.1",
32
- "redis": "2.8.0"
33
- },
34
- "devDependencies": {
35
- "eslint": "6.6.0",
36
- "eslint-config-airbnb": "18.0.1",
37
- "eslint-plugin-import": "2.18.2",
38
- "eslint-plugin-jsx-a11y": "6.2.3",
39
- "eslint-plugin-react": "7.16.0",
40
- "eslint-plugin-react-hooks": "2.2.0",
41
- "fancy-log": "1.3.3",
42
- "gulp": "4.0.2",
43
- "gulp-eslint": "6.0.0",
44
- "gulp-git": "2.9.0",
45
- "gulp-rename": "1.4.0",
46
- "husky": "3.0.9",
47
- "jsdoc-to-markdown": "5.0.2"
48
- }
49
- }