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);
});
-
options
- parameter is optional. See SMS API Reference
Contributing
- Include 100% test coverage.
- Follow the Hapi coding conventions
- Submit an issue first for significant changes