
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
redis-eventemitter
Advanced tools
Use redis as pubsub using a simple eventemitter.
npm install redis-eventemitter
var redis = require('redis-eventemitter');
var pubsub = redis({
prefix: 'production:',
url: 'redis://myuser:mypass@localhost:6379/'
// port: 6379,
// host: '127.0.0.1',
// auth_pass: 'mypassword'
// in case you want to control Redis clients
// creation you can specify pub/sub clients pair:
// pub: pubClient,
// sub: subClient
});
// Listen for messages on the *:newuser channel
pubsub.on('*:newuser', function(channel, user) {
console.log(channel); // prints "myservice:newuser"
console.log(user); // user is a json map as expected
});
// Publish an event "production:myservice:newuser" to the redis pubsub
pubsub.emit('myservice:newuser', { id:'a1b2c3', email:'foo@example.com' });
var redis = require('redis-eventemitter');
var pubsub = redis({ prefix: 'production:', host: 'localhost', port: 6379 });
pubsub.emit('myservice:newuser', { id:'a1b2c3' });
var redis = require('redis-eventemitter');
var pubsub = redis({ scope: 'production:', host: 'localhost', port: 6379 });
pubsub.on('*:newuser', function(channel, message) {
console.log(channel); // myservice:newuser
console.log(message); // { id:'a1b2c3' }
});
To be able to handle errors (like when the redis server is down) .on('error', ...)
should be used.
Note that this means that you can't listen for messages on the error
channel.
Removes listener.
Removes all listeners.
Port for the redis server.
Host for the redis server.
Url for the redis server.
Password for the redis server. Defaults to not being set.
A prefix that is added to the channel name, when publishing events to the redis pubsub. Useful for separating services or environments, e.g. production
, development
, and staging
.
It is also removed when the listeners is invoked.
Redis client instance used for publish
.
Redis client instance used for subscribe
.
FAQs
Redis pubsub using an event emitter
The npm package redis-eventemitter receives a total of 217 weekly downloads. As such, redis-eventemitter popularity was classified as not popular.
We found that redis-eventemitter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.