We will be developing an Email Newsletter to learn about Rust development.
As a blog visitor,
I want to subscribe to the newsletter,
So that I can receive email updates when new content is published on the blog.
As the blog author,
I want to send an email to all my confirmed subscribers,
So that I can notify them when new content is published.
Before running anything, add the following environment variable to .env
or export it.
DATABASE_URL=postgres://postgres:password@localhost:5432/newsletter
Then, start up the database Docker container.
$ ./scripts/init_db.sh
Run the following to start the application.
$ cargo run
You can also use cargo watch
to automatically run on any changes.
$ cargo install cargo-watch
$ cargo watch -x check -x test -x run
The code can be setup so that pushes to main
branch will trigger Continuous Deployment pipeline on DigitalOcean.
To authenticate yourself with DigitalOcean cli, use:
$ doctl auth init
To create app deployment, use:
$ doctl apps create --spec spec.yaml
To view the list of apps, use:
$ doctl apps list
Unfortunately, we are running database migrations manually.
First go to the DigitalOcean dashboard and disable "Trusted Sources" in the dev database. Then copy the database connection string and run the following migration:
$ DATABASE_URL=<DIGITALOCEAN_DATABASE_CONNECTION_STRING> sqlx migrate run