Socket
Socket
Sign inDemoInstall

@webgap/notifier

Package Overview
Dependencies
2
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @webgap/notifier

Webgap abstraction notification module.


Version published
Weekly downloads
1
Maintainers
1
Install size
272 kB
Created
Weekly downloads
 

Readme

Source

WebGAP Notifier

Build Status Test Coverage Code Climate Dependency Status

NPM version NPM downloads

README

This is the WebGAP Notifications Management module.
Handles abstraction for multiple notification mechanisms.

Dependencies

Handles most common object utilities with underscore.js.
Handles async implementation using async.

API

Installation

npm install @webgap/notifier --save

Usage

var notifier = require('@webgap/notifier');

// create Email Notification System Class 
function EmailSystem() {}

// EmailSystem must implement a notify function, doesn't matter how you implement it
EmailSystem.prototype.notify = function (options, callback) {
  console.log('\nEmail system send message: ' + JSON.stringify(options.notification));
  return callback();
};

// register the system
notifier.register({name: 'EMAIL', instance: new EmailSystem(), defaultSystem: true});
...
// register as many systems as you want - notifier.register({name, instance, defaultSystem});
...
// create notification object
var options = {
  notification: {
    userId: 'id of the user to notify',
    message: {
      key: 'messages.error.text',
      data: {errorCode: 111}
    }
  }
};
// notify using the default system
notifier.notify(options, function callback(err) {
  err && console.log(err);
});
...
// notify using specific system(s)
var options = {
  notification: {
    userId: 'id of the user to notify',
    message: {
      key: 'messages.error.text',
      data: {errorCode: 111}
    }
  },
  notificationSystems: [notifier.systems.EMAIL, notifier.systems.OTHER]
};
notifier.notify(options, function callback(err) {
  err && console.log(err);
});
...

Options

Register method accepts the following options:

var options = {
  name: 'name', // the name of the system
  instance: new SomeClass(), // the instance with a notify method
  defaultSystem: true // true or false, defaults to false
};

Notify method accepts the following options:

var options = {
 notification: {}, // an object with the notification that the instance can handle
 notificationSystems: [SystemA, SystemB] // an array with the system you want to notify with, if none is provided the default will be used. If none an error is returned
 };

License

Apache License, Version 2.0

Keywords

FAQs

Last updated on 15 Dec 2015

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc