Rust Domain Driven Design Example
Summery
This repository is used to present how I find implementing DDD in Rust projects works out
Framework
Running
- Clone the repository locally
https://github.com/behrouz-rfa/rust-ddd.git
-
Execute the
bin/dotenv
script to create a.env
file or copy the contents of the.env.sample
file into a new file with the name.env
-
Run the Docker
docker compose up -d
- Install dependencies and execute the server
cargo run
Examples
- For insert or registration
curl --location --request POST 'localhost:8082/api/users/insert' \
--header 'Content-Type: application/json' \
--data-raw '{
"username":"behrouz.r.fa",
"email":"[email protected]'\''",
"password":"pass@123"
}'
- for login
curl --location --request POST 'localhost:8082/api/users/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"email":"[email protected]'\''",
"password":"pass@123"
}'
- update user
curl --location --request PUT 'localhost:8082/api/user' \
--header 'Authorization: Token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NzMzMTY3OTUsImlkIjoyOCwidXNlcm5hbWUiOiJ0ZXN0MTEyMjIifQ._N82DPNiw27gVdBFuEPv2Tps_TbUH6wXgq-wBIxUQfc' \
--header 'Content-Type: application/json' \
--data-raw '{
"email":"[email protected]'\''",
"username":"master@123",
"bio": "this test for bio"
}'
TODO
- integration test
- fix db pool
- unit test
- Better error handling