sendgrid-stream

sends an email on each data event received

npm install sendgrid-stream
3 downloads in the last week
13 downloads in the last month

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 :).

install

npm install sendgrid-stream

Example

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);

test

npm test

license

MIT

npm loves you