Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

systemic-redis

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

systemic-redis - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

83

index.js

@@ -1,42 +0,61 @@

var async = require('async')
var get = require('lodash.get')
var format = require('util').format
module.exports = (options) => {
let redis = (options && options.redis) || require('redis');
let client;
let config;
let logger;
module.exports = function(options) {
const connectToRedis = () =>
new Promise((resolve) => {
client.on('ready', () => {
logger.info(`Connection to redis reached ready state.`);
resolve();
});
});
var redis = options && options.redis || require('redis')
var client
var config
var logger
const closeRedisConnection = () =>
new Promise((resolve, reject) => {
if (!client) {
reject(new Error('Client has not been initialized.'));
return;
}
function init(dependencies, cb) {
config = dependencies.config
logger = dependencies.logger || console
cb()
}
logger.info(`Disconnecting from ${config.url || config.host || '127.0.0.1'}`);
client.quit(() => {
resolve();
});
});
function validate(cb) {
if (!config) return cb(new Error('config is required'))
cb()
const start = async (dependencies) => {
config = { ...dependencies.config };
if (!config) {
throw new Error('config is required');
}
function start(cb) {
logger.info(format('Connecting to %s', config.url || config.host || '127.0.0.1'))
client = redis.createClient(config)
if (get(config, 'no_ready_check')) return cb(null, client)
client.on('ready', function() {
cb(null, client)
})
({ logger } = dependencies);
if (!logger) {
logger = console;
}
function stop(cb) {
if (!client) return cb()
logger.info(format('Disconnecting from %s', config.url || config.host || '127.0.0.1'))
client.quit(cb)
logger.info(`Connecting to ${config.url || config.host || '127.0.0.1'}`);
client = redis.createClient(config);
if (config.no_ready_check) {
connectToRedis();
} else {
await connectToRedis();
}
return {
start: async.seq(init, validate, start),
stop: stop
}
}
return client;
};
const stop = async () => {
await closeRedisConnection();
};
return {
start,
stop,
};
};
{
"name": "systemic-redis",
"version": "1.0.2",
"version": "2.0.0",
"description": "A systemic redis component",
"main": "index.js",
"engineStrict": true,
"engines": {
"node": ">=10.0.0",
"npm": ">=6.0.0"
},
"scripts": {

@@ -16,5 +21,3 @@ "test": "echo \"Error: no test specified\" && exit 1"

"dependencies": {
"async": "^2.0.0",
"lodash.get": "^4.3.0",
"redis": "^2.6.2"
"redis": "^3.0.2"
},

@@ -30,2 +33,2 @@ "devDependencies": {},

"homepage": "https://github.com/guidesmiths/systemic-redis#readme"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc