Skip to content

Instantly share code, notes, and snippets.

@motdotla
Last active December 20, 2015 21:29
Show Gist options
  • Save motdotla/6198268 to your computer and use it in GitHub Desktop.
Save motdotla/6198268 to your computer and use it in GitHub Desktop.
...
function findEmailAddresses(text) {
var emails = text.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
return emails;
}
var emails = {
...
parse: {
handler: function(request) {
var payload = request.payload;
var emails = findEmailAddresses(payload.text);
emails.forEach(function(email) {
db.sadd("emails", email);
});
request.reply({
success: true
});
}
}
};
server.route({
method : 'POST',
path : '/emails/parse',
config : emails.parse
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment