@mimik/rediser 1.2.5 → 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,34 @@
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
27
+ },
28
+ "settings":{
29
+ "react": {
30
+ "version": "latest"
31
+ }
15
32
  },
16
33
  "globals": {
17
34
  "module": true,
@@ -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/.nycrc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "exclude": ["gulpfile.js"],
3
+ "reporter": ["lcov", "text"]
4
+ }
package/Gulpfile.js CHANGED
@@ -1,29 +1,33 @@
1
1
  /* eslint-disable import/no-extraneous-dependencies */
2
+ const fs = require('fs');
2
3
  const log = require('fancy-log');
3
4
  const gulp = require('gulp');
4
5
  const eslint = require('gulp-eslint');
5
6
  const git = require('gulp-git');
6
- const gulpJsdoc2md = require('gulp-jsdoc-to-markdown');
7
- const rename = require('gulp-rename');
7
+ const jsdoc2md = require('jsdoc-to-markdown');
8
8
 
9
9
  const files = [
10
10
  'index.js',
11
11
  'Gulpfile.js',
12
- 'test/*.spec.js',
12
+ 'test/**.js',
13
+ 'lib/**.js',
13
14
  ];
14
15
 
15
- gulp.task('docs', () => gulp.src('index.js')
16
- .pipe(gulpJsdoc2md({ conf: 'jsdoc.json' }))
17
- .on('error', (err) => {
18
- log.error('docs creation failed:', err.message);
19
- })
20
- .pipe(rename('README.md'))
21
- .pipe(gulp.dest('.')));
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
+ .finally(() => done());
21
+ };
22
22
 
23
- gulp.task('lint', () => gulp.src(files)
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
- gulp.task('add', () => gulp.src('README.md')
29
- .pipe(git.add({ quiet: true })));
27
+ const add = () => gulp.src('README.md')
28
+ .pipe(git.add({ quiet: true }));
29
+
30
+ const docs = gulp.series(createDocs, add);
31
+
32
+ gulp.task('docs', docs);
33
+ gulp.task('lint', lint);
package/README.md CHANGED
@@ -17,7 +17,7 @@ const redis = require('@mimik/rediser');
17
17
  ### rediser~validate() ⇒ <code>Promise</code>
18
18
  Database connection validation.
19
19
 
20
- **Kind**: inner method of <code>[rediser](#module_rediser)</code>
20
+ **Kind**: inner method of [<code>rediser</code>](#module_rediser)
21
21
  **Returns**: <code>Promise</code> - .
22
22
  **Category**: async
23
23
  **Throws**:
@@ -33,7 +33,7 @@ Will exit 1 if the connection request times out and the connection state is not
33
33
  ### rediser~initializeSync() ⇒ <code>object</code>
34
34
  Database initialization.
35
35
 
36
- **Kind**: inner method of <code>[rediser](#module_rediser)</code>
36
+ **Kind**: inner method of [<code>rediser</code>](#module_rediser)
37
37
  **Returns**: <code>object</code> - The database object.
38
38
  **Category**: sync
39
39
  **Requires**: <code>module:sumologic-winston-logger</code>
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,45 +1,53 @@
1
1
  {
2
2
  "name": "@mimik/rediser",
3
- "version": "1.2.5",
3
+ "version": "1.4.6",
4
4
  "description": "Helper for setting up redis using redis for mimik microservices",
5
+ "main": "index.js",
5
6
  "scripts": {
6
7
  "lint": "gulp lint",
7
8
  "docs": "gulp docs",
8
- "test": "exit 0"
9
+ "test": "exit 0",
10
+ "prepublishOnly": "gulp docs; gulp lint; npm run test",
11
+ "commit-ready": "gulp docs; gulp lint; npm run test",
12
+ "prepare": "husky install"
9
13
  },
10
14
  "husky": {
11
15
  "hooks": {
12
- "pre-commit": "npm run lint; npm run docs; gulp add; npm run test",
13
- "pre-push": "npm run lint; npm run test"
16
+ "pre-commit": "npm run commit-ready",
17
+ "pre-push": "npm run test"
14
18
  }
15
19
  },
16
20
  "keywords": [
17
21
  "mimik",
18
22
  "microservice"
19
23
  ],
20
- "author": "mimik",
24
+ "author": "mimik technology inc <support@mimik.com> (https://developer.mimik.com/)",
21
25
  "license": "Apache-2.0",
22
26
  "repository": {
23
27
  "type": "git",
24
28
  "url": "https://bitbucket.org/mimiktech/rediser"
25
29
  },
26
30
  "dependencies": {
27
- "@mimik/sumologic-winston-logger": "1.1.1",
28
- "bluebird": "3.5.4",
29
- "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"
30
35
  },
31
36
  "devDependencies": {
32
- "eslint": "5.16.0",
33
- "eslint-config-airbnb": "17.1.0",
34
- "eslint-plugin-import": "2.17.2",
35
- "eslint-plugin-jsx-a11y": "6.2.1",
36
- "eslint-plugin-react": "7.12.4",
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",
37
45
  "fancy-log": "1.3.3",
38
- "gulp": "4.0.1",
39
- "gulp-eslint": "5.0.0",
40
- "gulp-git": "2.9.0",
41
- "gulp-jsdoc-to-markdown": "1.2.2",
42
- "gulp-rename": "1.4.0",
43
- "husky": "2.2.0"
46
+ "gulp": "4.0.2",
47
+ "gulp-eslint": "6.0.0",
48
+ "gulp-git": "2.10.1",
49
+ "gulp-rename": "2.0.0",
50
+ "husky": "7.0.4",
51
+ "jsdoc-to-markdown": "7.1.0"
44
52
  }
45
53
  }
package/jsdoc.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "source": {
3
- "includePattern": ".+\\.js(doc|x)?$",
4
- "excludePattern": ""
5
- }
6
- }