textmo

1.0.2 • Public • Published

Build Status Coverage Status Code Climate npm version dependencies Status Known Vulnerabilities NSP Status

textmo

A simple hapijs plugin for sending sms. Uses nexmo.

Installation

npm install textmo

Usage

const TextMo = require('textmo');
const server = new Hapi.Server();

const textMoConfig = {
    apiKey: 'safgd2143sgs',
    apiSecret: 'zx1j2h3g4g1jk',
    options: {}
};

server.register({
    plugin: TextMo,
    options: {
        config: textMoConfig
    }
});
  • apiKey - API Key from Nexmo
  • apiSecret - API SECRET from Nexmo
  • options - Additional options for the constructor

Options are:

{
  // If true, log information to the console
  debug: true|false,
  // append info the the User-Agent sent to Nexmo
  // e.g. pass 'my-app' for /nexmo-node/1.0.0/4.2.7/my-app
  appendToUserAgent: string,
  // Set a custom logger
  logger: {
    log: function() {level, args...}
    info: function() {args...},
    warn: function() {args...}
  }
}

Sending sms message

const smsConfig = {
    sender: 'Adam',
    recipient: '639183345789',
    message: 'Do not eat the fruit',
    options: {}
};


request.server.plugins.textmo.send(smsConfig)
    .then(function (res) {

        console.log(res)
    })
    .catch(function (err) {

        console.log(err);
    });

Contributing

Readme

Keywords

none

Package Sidebar

Install

npm i textmo

Weekly Downloads

10

Version

1.0.2

License

none

Last publish

Collaborators

  • dubrechi