A lightweight REST API for managing customer orders, built with Rust, Actix-web, PostgreSQL, and SQLx 0.8.
Includes a Postgres-backed repository and a fully in-memory repository for tests.
- Endpoints:
POST /orders— create orderGET /orders/{id}— get order by IDGET /orders— list all ordersPATCH /orders/{id}/status— update order statusDELETE /orders/{id}— delete order
- JSON Responses
- Repository trait with:
- PgPool implementation
- In-memory implementation (for tests)
- Tests require no database
- Rust (latest stable)
- Docker (for running Postgres)
- SQLx CLI: cargo install sqlx-cli --no-default-features --features postgres
docker-compose up -d
DATABASE_URL=postgres://postgres:postgres@localhost:5432/orders_db SERVER_BIND=127.0.0.1:8080
sqlx migrate run
cargo run
Runs fully in-memory (no DB needed):
cargo test