
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Pub/Sub for Node.js and MongoDB
vubsub is a Pub/Sub implementation for Node.js on top of MongoDB tailable cursors. vubsub was inspired by mubsub.
The main differences between vubsub and mubsub are:
vubsub uses Q, Kris Kowal's implementation of Promises.
npm install vubsub
To create a new client, simply call the create function passing a db instance and, optionally, a metadata object. If the metadata contains the ns key, it'll be used as the namespace for the client (i.e. the client will be linked to a collection named ns_namespace). The metadata is stored, together with the client id in the clients collection (you can you this to keep track of your clients).
var vubsub = require('vubsub')
, MongoClient = require('mongodb').MongoClient
MongoClient.connect('mongodb://localhost/test', { auto_reconnect: true }, function(err, db) {
if (err || !db) throw new Error('failed to connect to the db');
vubsub.create(db, { ns: 'myNamespace' }).then(function(client) {
console.log('Client connected: ' + client.id);
});
});
To create a channel and listen to events on the channel:
vubsub.create(db, { ns: 'myNamespace' }).then(function(client) {
return client.channel('myChannel' /*, you can pass here the id of the last received message */);
}).then(function(channel) {
console.log('Created channel ' + channel.name);
channel.on('myEvent', function(event) {
console.log('Received event', event);
});
});
To send a message to a channel:
channel.send('myEvent', { a: 1, b: 2}).then(function() {
console.log('Message sent');
});
FAQs
Pub/Sub for Node.js and MongoDB
The npm package vubsub receives a total of 7 weekly downloads. As such, vubsub popularity was classified as not popular.
We found that vubsub demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.