0.3.4 • Published 9 years ago
easy-notifier v0.3.4
EasyNotifier 
Flexible notifier with desktop and Slack targets.
Installation
npm install --save easy-notifierUsage
import EasyNotifier from 'easy-notifier';
let notifier = new EasyNotifier({ appName: 'example' });
notifier.notify('Welcome Message', 'Hello, World!');Concepts
Targets
You can configure the targets of the notifier.
For now, the supported targets are:
NodeNotifierTargetuses node-notifier to display the notifications.SlackIncomingWebhookTargetsends notifications to Slack using the incoming webhook API.
It is easy to create your own type of target. A target is just an object with a send(sender, title, message) method.
API
new EasyNotifier([options])
Create a notifier.
import EasyNotifier from 'easy-notifier';
let notifier = new EasyNotifier({ appName: 'example' });options
sender: the name of the sender. If not specified, a nice name is generated fromappName,hostNameandNODE_ENV.appName: the name of the running application.hostName: the name of the host where the application is running. If not specified,hostNameis determined from the hostname of the machine.targets: the targets where all notifications are sent. The default is an instance ofNodeNotifierTarget.includeEnvironment(default:true): iffalse, the current environment (NODE_ENV) is not included in thesendername.
notifier.addTarget(target)
Add a target to the notifier.
import { SlackIncomingWebhookTarget } from 'easy-notifier';
notifier.addTarget(new SlackIncomingWebhookTarget(/* webhook URL */));notifier.notify([title], message)
Send the specified message with an optional title. This method returns a promise which is resolved once the notification has been successfully sent.
notifier.notify('Welcome Message', 'Hello, World!');License
MIT