@ladjs/redis
Advanced tools
Comparing version 1.0.7 to 1.1.0
48
index.js
const IORedis = require('ioredis'); | ||
function getMeta(client) { | ||
function getMeta(client, hideMeta) { | ||
return { | ||
description: client._getDescription(), | ||
status: client.status || '[empty]' | ||
status: client.status || '[empty]', | ||
...(hideMeta ? { [hideMeta]: true } : {}) | ||
}; | ||
} | ||
function bindEvents(client, logger) { | ||
function bindEvents(client, logger, hideMeta) { | ||
client.on('connect', () => | ||
logger.debug('redis connection established', getMeta(client)) | ||
logger.debug('redis connection established', getMeta(client, hideMeta)) | ||
); | ||
client.on('ready', () => | ||
logger.debug('redis connection ready', getMeta(client)) | ||
logger.debug('redis connection ready', getMeta(client, hideMeta)) | ||
); | ||
client.on('error', (err) => logger.error(err, getMeta(client))); | ||
client.on('error', (error) => logger.error(error, getMeta(client, hideMeta))); | ||
client.on('close', () => | ||
logger.debug('redis connection closed', getMeta(client)) | ||
logger.debug('redis connection closed', getMeta(client, hideMeta)) | ||
); | ||
client.on('reconnecting', (time) => | ||
logger.debug('redis reconnecting', { time, ...getMeta(client) }) | ||
logger.debug('redis reconnecting', { time, ...getMeta(client, hideMeta) }) | ||
); | ||
client.on('end', () => | ||
logger.debug('redis connection ended', getMeta(client)) | ||
logger.debug('redis connection ended', getMeta(client, hideMeta)) | ||
); | ||
client.on('+node', () => | ||
logger.debug('redis node connected', getMeta(client)) | ||
logger.debug('redis node connected', getMeta(client, hideMeta)) | ||
); | ||
client.on('-node', () => | ||
logger.debug('redis node disconnected', getMeta(client)) | ||
logger.debug('redis node disconnected', getMeta(client, hideMeta)) | ||
); | ||
client.on('node error', (err, address) => | ||
logger.error(err, { address, ...getMeta(client) }) | ||
client.on('node error', (error, address) => | ||
logger.error(error, { address, ...getMeta(client, hideMeta) }) | ||
); | ||
@@ -44,3 +45,4 @@ } | ||
maxListeners = 15, | ||
_bindEvents = true | ||
_bindEvents = true, | ||
hideMeta = 'hide_meta' | ||
) { | ||
@@ -51,6 +53,9 @@ const client = new IORedis(config); | ||
if (monitor) { | ||
client.monitor((err, monitor) => { | ||
if (err) return logger.error(err, getMeta(client)); | ||
client.monitor((error, monitor) => { | ||
if (error) { | ||
return logger.error(error, getMeta(client, hideMeta)); | ||
} | ||
logger.debug('redis monitor instance created', { | ||
...getMeta(client), | ||
...getMeta(client, hideMeta), | ||
monitor | ||
@@ -61,3 +66,3 @@ }); | ||
logger.debug('redis monitor', { | ||
...getMeta(client), | ||
...getMeta(client, hideMeta), | ||
time, | ||
@@ -69,7 +74,10 @@ args, | ||
); | ||
bindEvents(monitor, logger); | ||
bindEvents(monitor, logger, hideMeta); | ||
}); | ||
} | ||
if (_bindEvents) bindEvents(client, logger); | ||
if (_bindEvents) { | ||
bindEvents(client, logger, hideMeta); | ||
} | ||
return client; | ||
@@ -76,0 +84,0 @@ } |
{ | ||
"name": "@ladjs/redis", | ||
"description": "Redis for Lad", | ||
"version": "1.0.7", | ||
"version": "1.1.0", | ||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
"ava": { | ||
"failFast": true, | ||
"verbose": true | ||
}, | ||
"bugs": { | ||
@@ -14,7 +10,2 @@ "url": "https://github.com/ladjs/redis/issues", | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"contributors": [ | ||
@@ -24,33 +15,29 @@ "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)" | ||
"dependencies": { | ||
"ioredis": "^4.17.3" | ||
"ioredis": "^5.2.4" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^9.1.1", | ||
"@commitlint/config-conventional": "^9.1.1", | ||
"ava": "^3.10.1", | ||
"codecov": "^3.7.1", | ||
"cross-env": "^7.0.2", | ||
"delay": "^4.4.0", | ||
"eslint": "7.5.0", | ||
"eslint-config-xo-lass": "^1.0.3", | ||
"@commitlint/cli": "^17.3.0", | ||
"@commitlint/config-conventional": "^17.3.0", | ||
"ava": "^5.1.0", | ||
"cross-env": "^7.0.3", | ||
"delay": "^5.0.0", | ||
"eslint": "8.29.0", | ||
"eslint-config-xo-lass": "^2.0.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"fixpack": "^3.0.6", | ||
"husky": "^4.2.5", | ||
"lint-staged": "^10.2.11", | ||
"fixpack": "^4.0.0", | ||
"husky": "^8.0.2", | ||
"lint-staged": "^13.1.0", | ||
"nyc": "^15.1.0", | ||
"remark-cli": "^8.0.1", | ||
"remark-preset-github": "^2.0.2", | ||
"sinon": "^9.0.2", | ||
"xo": "^0.32.1" | ||
"remark-cli": "^11.0.0", | ||
"remark-preset-github": "^4.0.4", | ||
"sinon": "^15.0.0", | ||
"xo": "^0.53.1" | ||
}, | ||
"engines": { | ||
"node": ">=8.3" | ||
"node": ">=14" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"homepage": "https://github.com/ladjs/redis", | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged && npm test", | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS" | ||
} | ||
}, | ||
"keywords": [ | ||
@@ -92,30 +79,6 @@ "agenda", | ||
"license": "MIT", | ||
"lint-staged": { | ||
"*.js": [ | ||
"xo --fix", | ||
"git add" | ||
], | ||
"*.md": [ | ||
"remark . -qfo", | ||
"git add" | ||
], | ||
"package.json": [ | ||
"fixpack", | ||
"git add" | ||
] | ||
}, | ||
"main": "index.js", | ||
"prettier": { | ||
"singleQuote": true, | ||
"bracketSpacing": true, | ||
"trailingComma": "none" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"remarkConfig": { | ||
"plugins": [ | ||
"preset-github" | ||
] | ||
}, | ||
"repository": { | ||
@@ -126,14 +89,7 @@ "type": "git", | ||
"scripts": { | ||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", | ||
"lint": "xo && remark . -qfo", | ||
"test": "npm run lint && npm run test-coverage", | ||
"test-coverage": "cross-env NODE_ENV=test nyc ava" | ||
}, | ||
"xo": { | ||
"prettier": true, | ||
"space": true, | ||
"extends": [ | ||
"xo-lass" | ||
] | ||
"lint": "xo --fix && remark . -qfo && fixpack", | ||
"prepare": "husky install", | ||
"pretest": "npm run lint", | ||
"test": "cross-env NODE_ENV=test nyc ava" | ||
} | ||
} |
# [**@ladjs/redis**](https://github.com/ladjs/redis) | ||
[![build status](https://img.shields.io/travis/ladjs/redis.svg)](https://travis-ci.org/ladjs/redis) | ||
[![code coverage](https://img.shields.io/codecov/c/github/ladjs/redis.svg)](https://codecov.io/gh/ladjs/redis) | ||
[![build status](https://github.com/ladjs/redis/actions/workflows/ci.yml/badge.svg)](https://github.com/ladjs/redis/actions/workflows/ci.yml) | ||
[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) | ||
@@ -29,9 +28,3 @@ [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) | ||
[yarn][]: | ||
```sh | ||
yarn add @ladjs/redis | ||
``` | ||
## Usage | ||
@@ -52,8 +45,6 @@ | ||
## | ||
## | ||
[npm]: https://www.npmjs.com/ | ||
[yarn]: https://yarnpkg.com/ | ||
[redis]: https://github.com/luin/ioredis |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
16
6326
4
75
49
2
+ Added@ioredis/commands@1.2.0(transitive)
+ Addeddenque@2.1.0(transitive)
+ Addedioredis@5.4.1(transitive)
- Removeddenque@1.5.1(transitive)
- Removedioredis@4.28.5(transitive)
- Removedlodash.flatten@4.4.0(transitive)
- Removedp-map@2.1.0(transitive)
- Removedredis-commands@1.7.0(transitive)
Updatedioredis@^5.2.4