@mimik/rediser 1.3.1 → 1.4.8

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,21 +1,33 @@
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": {
9
- "brace-style": [1, "stroustrup", {"allowSingleLine": true}],
14
+ "import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
15
+ "import/no-unresolved": ["error", { "amd": true, "commonjs": true, "caseSensitiveStrict": true }],
16
+ "brace-style": [1, "stroustrup", { "allowSingleLine": true }],
10
17
  "no-confusing-arrow": [0], // arrow isnt confusing
11
18
  "max-len": [1, 180, { "ignoreComments": true }],
12
19
  "linebreak-style": 0,
13
20
  "quotes": [1, "single"],
14
- "semi": [1, "always"]
21
+ "semi": [1, "always"],
22
+ "no-process-env": ["error"],
23
+ "@mimik/document-env/validate-document-env": 2,
24
+ "@mimik/dependencies/case-sensitive": 2,
25
+ "@mimik/dependencies/no-cycles": 2,
26
+ "@mimik/dependencies/require-json-ext": 2
15
27
  },
16
28
  "settings":{
17
29
  "react": {
18
- "version": "latest"
30
+ "version": "detect"
19
31
  }
20
32
  },
21
33
  "globals": {
@@ -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/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,16 @@
1
1
  {
2
2
  "name": "@mimik/rediser",
3
- "version": "1.3.1",
3
+ "version": "1.4.8",
4
4
  "description": "Helper for setting up redis using redis for mimik microservices",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "lint": "gulp lint",
8
- "docs": "gulp docs",
9
- "test": "exit 0",
10
- "commit-ready": "gulp docs; gulp lint; npm run test"
7
+ "lint": "eslint --ignore-path .gitignore .",
8
+ "docs": "jsdoc2md index.js > README.md",
9
+ "test": "echo \"Error: no test specified\" && exit 0",
10
+ "test-ci": "echo \"Error: no test specified\" && exit 0",
11
+ "prepublishOnly": "npm run docs && npm run lint && npm run test-ci",
12
+ "commit-ready": "npm run docs && npm run lint && npm run test-ci",
13
+ "prepare": "husky install"
11
14
  },
12
15
  "husky": {
13
16
  "hooks": {
@@ -19,30 +22,28 @@
19
22
  "mimik",
20
23
  "microservice"
21
24
  ],
22
- "author": "mimik",
23
- "license": "Apache-2.0",
25
+ "author": "mimik technology inc <support@mimik.com> (https://developer.mimik.com/)",
26
+ "license": "MIT",
24
27
  "repository": {
25
28
  "type": "git",
26
29
  "url": "https://bitbucket.org/mimiktech/rediser"
27
30
  },
28
31
  "dependencies": {
29
- "@mimik/sumologic-winston-logger": "1.3.0",
30
- "bluebird": "3.7.1",
31
- "redis": "2.8.0"
32
+ "@mimik/lib-filters": "^1.4.4",
33
+ "@mimik/sumologic-winston-logger": "^1.6.8",
34
+ "bluebird": "3.7.2",
35
+ "redis": "4.1.0"
32
36
  },
33
37
  "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",
40
- "fancy-log": "1.3.3",
41
- "gulp": "4.0.2",
42
- "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"
38
+ "@mimik/eslint-plugin-dependencies": "^2.4.3",
39
+ "@mimik/eslint-plugin-document-env": "^1.0.3",
40
+ "eslint": "8.15.0",
41
+ "eslint-config-airbnb": "19.0.4",
42
+ "eslint-plugin-import": "2.26.0",
43
+ "eslint-plugin-jsx-a11y": "6.5.1",
44
+ "eslint-plugin-react": "7.29.4",
45
+ "eslint-plugin-react-hooks": "4.5.0",
46
+ "husky": "8.0.1",
47
+ "jsdoc-to-markdown": "7.1.1"
47
48
  }
48
49
  }
package/Gulpfile.js DELETED
@@ -1,34 +0,0 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
- const fs = require('fs');
3
- const log = require('fancy-log');
4
- const gulp = require('gulp');
5
- const eslint = require('gulp-eslint');
6
- const git = require('gulp-git');
7
- const jsdoc2md = require('jsdoc-to-markdown');
8
-
9
- const files = [
10
- 'index.js',
11
- 'Gulpfile.js',
12
- 'test/**.js',
13
- 'lib/**.js',
14
- ];
15
-
16
- const createDocs = (done) => {
17
- jsdoc2md.render({ files: 'index.js' })
18
- .then((output) => fs.writeFileSync('README.md', output))
19
- .catch((err) => log.error('docs creation failed:', err.message));
20
- return done();
21
- };
22
-
23
- const lint = () => gulp.src(files)
24
- .pipe(eslint({}))
25
- .pipe(eslint.format())
26
- .pipe(eslint.failOnError());
27
-
28
- const add = () => gulp.src('README.md')
29
- .pipe(git.add({ quiet: true }));
30
-
31
- const docs = gulp.series(createDocs, add);
32
-
33
- gulp.task('docs', docs);
34
- gulp.task('lint', lint);
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
- }