2.3.0 • Published 3 years ago

app-notify v2.3.0

Weekly downloads
24
License
ISC
Repository
github
Last release
3 years ago

app-notify

Send Twilio SMS and SMTP email notifications from within your node.js app

install

npm install app-notify
const Notify = require('app-notify');
const cfg = {...};
const notify = new Notify(cfg);

usage (promises)

Send an email message:

const cfg = {};

//setup smtp server
cfg.smtp = {
    host: xxx,
    user: user,
    pass: pass,
    port: port
};

//setup email headers
cfg.email = {
    to: 'user@example.com',
    from: 'sender@example.com'
};

const Notify = require('app-notify');
const notify = new Notify(cfg);

//send an email
notify.email.send({
    subject: 'This is a test',
    message: 'Hello world!'
})
.then(function(data){
    console.log(data);
})
.catch(function(err){
    console.error(err);
});

Send an SMS message

const cfg = {};

//setup sms configuration
cfg.sms = {
    sid: 'twilio-sid-id',
    auth: 'twilio-auth-id',
    to: 'xxx-xxx-xxxx', //recipient
    from: 'yyy-yyy-yyyy' //your twilio assigned phone number
};

const Notify = require('app-notify');
const notify = new Notify(cfg);

notify.sms.send({
    message: 'Hello world'
})
.then(function(data){
    console.log(data);
})
.catch(function(err){
    console.error(err);
});

Send to whichever services we have enabled (both sms and email):

const cfg = {};

//setup smtp server
cfg.smtp = {
    host: xxx,
    user: user,
    pass: pass,
    port: port
};

//setup email headers
cfg.email = {
    to: 'user@example.com',
    from: 'sender@example.com'
};

const Notify = require('app-notify');
const notify = new Notify(cfg);

//sends both
notify.send({
    subject: 'This is a test',
    message: 'Hello world'
});

//disable email
notify.cfg.email.disabled = true;

//sends only sms
notify.send({
    message: 'Hello world',
});

usage (callbacks)

app-notify can be used with callbacks too!

run tests

gulp test
2.3.0

3 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

11 years ago

1.3.1

11 years ago

1.2.0

11 years ago

1.1.1

11 years ago

1.1.0

11 years ago

1.0.0

11 years ago