A Clean Architecture template for a Rest API in rust
Motivations, explanations, requirements & more details in my article Practical Clean Architecture in Typescript, Rust & Python
cargo build
It's currently configured to run with PostgreSQL through Diesel (ORM), but this being clean architecture feel free to change it :)
I suggest
Then install diesel_cli
diesel setup --database-url postgresql://postgres:postgres@localhost/animal_fact_db
diesel migration run --database-url postgresql://postgres:postgres@localhost/animal_fact_db
define the environment on which we're running by adding ENV=<env>
, which will use the .env.<env>
file
ENV=dev cargo run
Used in CI/CD
cargo fmt --all -- --check
cargo clippy --all-targets
cargo audit
cargo outdated
Here's what done in order to mock the SPI
- db: every test is creating a new database from
TestContextPostgreSQL
with json fixtures intest/fixtures
& spawns the app with this database - http: every test also spins up another rust api (if not already up) with the expected routes but test data in
test/fixtures
ENV=test cargo test