JSPM

system-notifier

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q43116F
  • License MIT

System notifier sending Telegram message and SMS

Package Exports

  • system-notifier

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (system-notifier) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

system-notifier Build Status Coverage Status

System notifier sending Telegram message and SMS.

Installation

npm install system-notifier

Usage

const SystemNotifier = require('system-notifier');
/** Or with ES6+ */
import SystemNotifier from 'system-notifier';

const notifier = new SystemNotifier({
  prefix: 'domain.com',
  telegram: {
    botToken: process.env.TELEGRAM_BOT_TOKEN,
    chatId: process.env.TELEGRAM_CHAT_ID
  },
  twilio: {
    authToken: process.env.TWILIO_AUTH_TOKEN,
    accountSID: process.env.TWILIO_ACCOUNT_SID,
    fromNumber: process.env.TWILIO_FROM_NUMBER,
    toNumber: process.env.TWILIO_TO_NUMBER
  }
})

Then, call notifier.notify function with your message:

notifier.notify('Internal Server Error...');

You can add an emoji prefix with one of the following codes: info (ℹ️), error (❌), warning (⚠️) or success (✅).

notifier.notify('Internal Server Error...', 'error');

Build

npm run build

Testing

Create a .env file and add your providers credentials:

TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=
TWILIO_AUTH_TOKEN=
TWILIO_ACCOUNT_SID=
TWILIO_FROM_NUMBER=
TWILIO_TO_NUMBER=
npm test

License

This project is licensed under the MIT license.