🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

seal-mongo-notification

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seal-mongo-notification

An event emitter that uses MongoDB capped collections.

1.0.9
latest
Source
npm
Version published
Maintainers
1
Created
Source

seal-mongo-notification

CircleCI AppVeyor

An event emitter and receiver that uses MongoDB capped collections.

Installation

$ npm install seal-mongo-notification

Quick start

First you need to add a reference to seal-mongo-notification to your application.

const mongoNotification = require('seal-mongo-notification');

Then connect to a MongoDB by calling the function mongoNotification. Provide an options object and a callback:

mongoNotification({
  url: 'mongodb://...',
  topic: 'messages',
  writeOnly: false
}, (err, notification) => {
  // ...
});

The options contain:

  • url mandatory, a connection string,
  • topic mandatory, the name of a topic collection
  • writeOnly optional, the open mode, default: false

Emit events

Call the emit function for actually emitting an event:

notification.emit('foo', { foo: 'bar' });

Optionally you may specify a callback to get notified when the event has been persisted:

notification.emit('foo', { foo: 'bar' }, (err) => {
  // ...
});

Receive events

If you want to receive events send by your application use the on function:

notification.on('foo', (payload) => {
  // ...
});

Write only mode

If you only want to emit events but not receive any you can set the writeOnly option to true when connecting.

mongoNotification({
  ...
  writeOnly: true
}, (err, notification) => {
  // ...
});

Running the build

To build this module use roboter.

$ bot

FAQs

Package last updated on 26 Feb 2019

Did you know?

Socket

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.

Install

Related posts