stream based email trigger using `sendgrid-web`
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
test
.gitignore
LICENSE
README.md
index.js
package.json

README.md

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