Skip to content

Instantly share code, notes, and snippets.

@rbren
Created January 28, 2016 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbren/538aba01413e5db4c823 to your computer and use it in GitHub Desktop.
Save rbren/538aba01413e5db4c823 to your computer and use it in GitHub Desktop.
Product Hunt Alerts

DataFire Dataflow: Product Hunt Alerts

Get a daily e-mail with any products that match your query

View on DataFire

// GET https://api.producthunt.com/v1/categories/{category}/posts
function request(data) {
return {category: constants.category || "tech"}
}
// POST https://datafire.io/services/mail/send
function request(data) {
var query = (constants.query || '').toLowerCase();
var posts = data[0].posts.filter(function(post) {
var searchText = post.name.toLowerCase() + " " + post.tagline.toLowerCase();
return searchText.indexOf(query) !== -1;
})
if (!posts.length) return [];
var message = posts.map(function(post) {
return '<h2>' + post.name + '</h2>' +
'<h4>' + post.tagline + '&nbsp;&nbsp;' +
'<small><a href="' + post.discussion_url + '">View on Product Hunt</a></small></h4>' +
'<img src="' + post.thumbnail.image_url + '">';
}).join('<br>');
return {
body: {
to: constants.email,
subject: "Product Hunt - Today's Products " + (constants.query ? ("matching " + constants.query) : ""),
message: message,
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment