Last active
January 20, 2025 13:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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