-
Notifications
You must be signed in to change notification settings - Fork 6
3. Running the Code
Running the project might be a little more complicated than you'd expect but I assure you, it is for good reasons!
This project can be run locally/on AWS in debug/release mode.
The practical difference between debug and release is that debug does not send the actual emails and hence does not require you to
specify the API_KEY
and EMAIL_ADDRESS
environment variables which means that you can just cargo run
and you'll be up and running in no time.
Debug mode dumps the HTML you would receive in your email in the console. Feel free to place that in an HTML file or on a website like this to see what it would look like.
As stated earlier, release will need you to specify an API_KEY
and EMAIL_ADDRESS
, everything else should work the same.
I make use of conditional compilation which is a fancy way of saying I only include some pieces of code IF you decide to run the project on Lambda to make this easy to work within a local environment. Lambda deployments in this case rely on dockerizing the code for which simply refer to here.
Note that all of the following can be defined as environment variables and you can skip creating the file completely. This is recommended when deploying as editing these values is easier!
Copy the contents of .env.example
into a new .env
file.
-
API_KEY
is unsurprisingly meant for your API key (only needed for release) -
EMAIL_ADDRESS
is for your sender email address (only needed for release) -
RECIPIENT_ADDRESSES
: comma-delimited list of recipient email addresses (only needed for release) -
SUBJECT
: the email subject (only needed for release) -
DAYS
is an optional parameter (defaults to7
) that tells the code how many days before the time of execution it should look for blog posts. -
FEEDS
should contain a;
delimited list of links that leed to web feeds (alternatively you can put these in afeeds.txt
file. -
EMAIL
your email provider (SENDGRID
,RESEND
orMAIL_COMMAND
, defaults to sendgrid)
Right now, emails are sent to and from the same account as that works fine for me, if you have a separate email that you want to use then let me know by creating an issue and I'll implement that!
If you defined your feeds in the aforementioned environment variable, you can skip this step!
Create a file feeds.txt
and place some links inside of it like so:
https://antoniosbarotsis.github.io/index.xml
https://blog.rust-lang.org/feed.xml
https://blog.rust-lang.org/inside-rust/feed.xml
https://github.blog/feed
Not all blogs tell you where their RSS feed is stored but I found that almost all of them have one. In the blogs that I tried this with, the XML file was usually in one of the following locations:
./index.xml
./rss
./feed
./feed.xml
If these don't work, try using Inspect Element in your browser and look for rss
Example:
<link
rel="alternate"
type="application/rss+xml"
title="The GitHub Blog » Feed"
href="https://github.blog/feed/"
>