Get alerted of top HN posts every hour
Just show me the code
YOUR_DISCORD_WEBHOOK_URL
with your Discord webhook URL, and then you can run the following in your terminal:View example output of HN posts
format
: formats story data into Discord markdownnotify
: sends an alert to Discord via webhook URLreq.body.$previous
.
Example using the `$previous` metadata
$previous
data:body
for our job, we can write it like this:https://yourdomain.com/api/hn
, you can create your scheduled job by running the following script in your terminal with your BOOPER_API_KEY
set, and the url
modified to the appropriate domain:state
, which can be accessed at req.body.$state
and set or updated in the response.
Example using the schedule `$state`
$state
:$previous
metadata, but there is one key difference: while $previous
data is ephemeral, the schedule’s $state
is stored in the database. This means that if a schedule is paused and then restarted again, the $previous
data will be lost, but $state
will be persisted.Once again, we can clean this up a bit by taking advantage of dynamic values in our job schedule configuration. When we set the request body
for our job, we can write it like this:https://yourdomain.com/api/hn
, you can create your scheduled job by running the following script in your terminal with your BOOPER_API_KEY
set, and the url
modified to the appropriate domain: