sendgrid-stream

sends an email on each data event received

sendgrid-stream

A simple Transform stream that sends the data it recieves in an email using sendgrid-web. It is recommended that you have a filtering stream of sorts before piping to this :).

npm install sendgrid-stream
var sendgridStream = require('../');
 
// 
// Instantiates the stream with `sendgrid-web` info 
// 
var stream = sendgridStream({
  auth: {
    user: 'username',
    key: 'password'
  },
  to: 'devops@domain.com',
  from: 'service@domain.com',
  subject: 'Error'
});
 
// 
// Log any errors to the console 
// 
stream.on('error', console.error.bind(console));
 
var data = {
  key: 'value',
  otherKey: 'otherValue'
};
 
// 
// Same data is passed through to the otherside of the stream 
// 
stream.on('readable', function () {
  var thing = stream.read();
  console.log(thing);
});
 
// 
// This will trigger an email to be sent with the `data` object 
// 
stream.write(data);
npm test

MIT