Skip to content

hazadus/rust-newsletter

Repository files navigation

rust-newsletter

Rust

Simple newsletter app, written in Rust.

Based on Luca Palmieri's awesome book with some improvements.

References

Starting app in dev mode

Run the PostgreSQL container and apply the migration:

./scripts/init_db.sh

Start the app:

cargo run

Or, see Makefile for make commands.

Tests

./scripts/init_db.sh
TEST_LOG=true cargo test | bunyan

Tooling

Docker

docker build --tag newsletter --file Dockerfile .
docker run -p 8000:8000 newsletter
# Check it is working:
curl -v http://127.0.0.1:8000/health_check
# Push image to the Docker Hub:
docker tag newsletter hazadus/rust-newsletter
docker push hazadus/rust-newsletter

Working with sqlx

Install sqlx-cli:

# Note the version
cargo install --version=0.5.7 sqlx-cli --no-default-features --features postgres
# Check installation
sqlx --help
# Prepare offline DB data
cargo sqlx prepare -- --lib
# Check offline data
cargo sqlx prepare --check -- --bin newsletter

Using cargo-udeps

cargo install cargo-udeps
cargo +nightly udeps

Test logs pretty print

cargo install bunyan
TEST_LOG=true cargo test | bunyan