easy-notifier

2019-07-21

easy-notifier是什么

什么是easy-notifier,Flexible notifier with desktop and Slack targets

easy-notifier使用教程帮助文档

EasyNotifier Build Status

Flexible notifier with desktop and Slack targets.

Installation

npm install --save easy-notifier

Usage

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:

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 from appName, hostName and NODE_ENV.
  • appName: the name of the running application.
  • hostName: the name of the host where the application is running. If not specified, hostName is determined from the hostname of the machine.
  • targets: the targets where all notifications are sent. The default is an instance of NodeNotifierTarget.
  • includeEnvironment _(default: true)_: if false, the current environment (NODE_ENV) is not included in the sender name.

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


上一篇:event-emitter-mixin
下一篇:aws-as-promised
相关文章

首次访问,人机识别验证

扫描下方二维码回复 1024 获取验证码,验证完毕后 永久 无须验证

操作步骤:[打开微信]->[扫描上侧二维码]->[关注 FedJavaScript 的微信] 输入 1024 获取验证码

验证码有误,请重新输入