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

haraka-plugin-redis

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

haraka-plugin-redis - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

23

Changes.md
### 2.0.4 - 2022-05-25
### 2.0.5 - 2022-05-26
- fix: backwards compatibility with legacy plugin config files
- fix: rename p\* methods -> * (required in redis v4)
- fix: add `await ...connect()` as is now required, fixes #32
- fix: make redis_ping async function
- fix: add `await client.connect()` as is now required, fixes #32
- fix: make redis_ping async
- dep(redis): bump 4.0 -> 4.1
- ci: updated syntax
- chore(ci): updated syntax
- chore(ci): added codeql config
- test: added tests for init_redis_plugin

@@ -15,6 +17,5 @@

- bump redis major version 3 -> 4
- API change, callbacks replaced by promises
- dep(redis): bump major version 3 -> 4
- breaking API change: replaced callbacks with promises
- config.ini
- [server] -> [socket]
- opts.db -> opts.database (to match upstream)

@@ -25,4 +26,4 @@

- switch CI from Travis to GitHub Actions
- README: update formatting with GFM
- chore(ci): switch CI from Travis to GitHub Actions
- doc(README): update formatting with GFM

@@ -32,4 +33,4 @@

- replace nodeunit with mocha
- update redis lib to v3
- chore(ci): replace nodeunit with mocha
- dep(redis): update lib to v3
- appveyor: test on node 10

@@ -36,0 +37,0 @@

@@ -18,2 +18,3 @@ 'use strict';

const defaultOpts = { socket: { host: '127.0.0.1', port: '6379' } }
const socketOpts = [ 'host', 'port', 'path', 'tls', 'connectTimeout', 'noDelay', 'keepAlive', 'reconnectStrategy' ]

@@ -29,17 +30,23 @@ exports.load_redis_ini = function () {

const rc = plugin.redisCfg;
plugin.redisCfg.server = Object.assign({}, defaultOpts, rc.opts, rc.socket);
// backwards compat
if (rc.server.ip && !rc.server.host) {
rc.server.host = rc.server.ip
delete rc.server.ip
if (plugin.redisCfg?.server?.ip && !plugin.redisCfg?.server?.host) {
plugin.redisCfg.server.host = plugin.redisCfg.server.ip
delete plugin.redisCfg.server.ip
}
if (plugin.redisCfg.db && !plugin.redisCfg.database) {
plugin.redisCfg.database = plugin.redisCfg.db
delete plugin.redisCfg.db
}
// backwards compat with node-redis < 4
if (rc.db && !rc.database) {
rc.database = rc.db
plugin.redisCfg.server = Object.assign({}, defaultOpts, plugin.redisCfg.opts, plugin.redisCfg.server);
plugin.redisCfg.pubsub = Object.assign({}, defaultOpts, plugin.redisCfg.opts, plugin.redisCfg.pubsub);
// socket options. In redis < 4, the options like host and port were
// top level, now they're in socket.*. Permit legacy configs to still work
for (const s of [ 'server', 'pubsub' ]) {
for (const o of socketOpts) {
if (plugin.redisCfg[s][o]) plugin.redisCfg[s].socket[o] = plugin.redisCfg[s][o]
delete plugin.redisCfg[s][o]
}
}
plugin.redisCfg.pubsub = Object.assign({}, defaultOpts, rc.opts, rc.socket, rc.pubsub);
}

@@ -54,2 +61,13 @@

this.cfg.redis = Object.assign({}, this.redisCfg.server, this.cfg.redis);
// backwards compatibility
for (const o of socketOpts) {
if (this.cfg.redis[o] === undefined) continue
this.cfg.redis.socket[o] = this.cfg.redis[o]
delete this.cfg.redis[o]
}
if (this.cfg.redis.db && !this.cfg.redis.database) {
this.cfg.redis.database = this.cfg.redis.db
delete this.cfg.redis.db
}
}

@@ -98,3 +116,3 @@

// tests that do not load config
// for tests that do not load a shared config
if (!plugin.cfg) {

@@ -101,0 +119,0 @@ plugin.cfg = { redis: {} };

{
"name": "haraka-plugin-redis",
"version": "2.0.4",
"version": "2.0.5",
"description": "Redis plugin for Haraka & other plugins to inherit from",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -18,3 +18,3 @@ 'use strict';

this.plugin = new fixtures.plugin('index')
this.plugin.register()
this.plugin.config = this.plugin.config.module_config(path.resolve('test'));
})

@@ -27,2 +27,3 @@

it('config defaults', async function () {
this.plugin.load_redis_ini();
assert.equal(this.plugin.redisCfg.server.socket.host, '127.0.0.1')

@@ -33,7 +34,5 @@ assert.equal(this.plugin.redisCfg.server.socket.port, 6379)

it('merges [opts] into server config', async function () {
this.plugin.config = this.plugin.config.module_config(path.resolve('test'));
this.plugin.load_redis_ini();
assert.deepEqual(this.plugin.redisCfg, {
main: {},
socket: {},
pubsub: {

@@ -60,15 +59,12 @@ socket: {

it('merges redis.ini [opts] into plugin config', async function () {
this.plugin.config = this.plugin.config.module_config(path.resolve('test'));
this.plugin.load_redis_ini();
this.plugin.cfg = {};
this.plugin.merge_redis_ini();
assert.deepEqual(this.plugin.cfg, {
redis: {
socket: {
host: '127.0.0.1',
port: '6379',
},
database: 5,
password: 'dontUseThisOne'
}
assert.deepEqual(this.plugin.cfg.redis, {
socket: {
host: '127.0.0.1',
port: '6379',
},
database: 5,
password: 'dontUseThisOne'
})

@@ -119,3 +115,3 @@ })

describe('init_redis_plugin', function () {
before(async function () {
before(function () {
this.server = { notes: { } }

@@ -125,2 +121,3 @@

this.plugin.register()
this.plugin.merge_redis_ini()
})

@@ -127,0 +124,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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