WebGAP Notifier
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');
function EmailSystem() {}
EmailSystem.prototype.notify = function (options, callback) {
console.log('\nEmail system send message: ' + JSON.stringify(options.notification));
return callback();
};
notifier.register({name: 'EMAIL', instance: new EmailSystem(), defaultSystem: true});
...
...
var options = {
notification: {
userId: 'id of the user to notify',
message: {
key: 'messages.error.text',
data: {errorCode: 111}
}
}
};
notifier.notify(options, function callback(err) {
err && console.log(err);
});
...
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',
instance: new SomeClass(),
defaultSystem: true
};
Notify method accepts the following options:
var options = {
notification: {},
notificationSystems: [SystemA, SystemB]
};
License
Apache License, Version 2.0