Example api project using Rust, with warp and sqlx.
/domain
Implementation of the business rules
/db
Sqlx database adapter
/migrations
sql schema to run with sqlx-cli
/api
Api entry points calling the domain
/commands
Command line utilities calling the domain
/main
/adapters
Adapters wrapping external libraries to implement traits provided by the domain
/main.rs
Entry point of the application
/service_registry.rs
Factories to create the concrete types of many dependencies
/util.rs
Some utility functions
/features
Scenarios to run with karate
/atomic_counter
A simple thread safe counter
/println_logger
A simple logger based on println!
/simple_counter
A counter which is not thread safe.
Used to illustrate how to use an adapter with an Arc and a Mutex
/uppercaser
A simple stateless library
- Create services and wire them together
- Use injection through generic
- Use injection through dyn Trait
- Each services can be injected in many consumers
- Each services can hold a mutable state
- Service consumers must expose a trait
- Services should not explicitely implement their consumers traits
- Adapters wrap services into a struct implementing the expected trait
- Run unit tests with equality assertions
- Create mocks implementing a trait returning a predefined value
- Generate a coverage report
- Inject mocks with spies to test wether a dependency was called
- Split one project in multiple files
- Split in multiple projects
- Use cargo workspaces
- Seperate error between services and consumers
- Try anyhow
- Try thiserror
- Enrich errors with origin
- Enrich errors with a message
- Add logs
- Setup sqlx
- Setup migrations
- Run at least one data query with sqlx
- Run at least one data update query with sqlx
- Transactions
- Setup a web framework to return json
- Route to get all posts
- Route to create a post
- Route to publish a post
- Route to unpublish a post
- Investigate open api v3
- Return meaningfull errors for 4** status codes
- Return 500 on internal errors
- Return a request id in a header
- Environment variables
- Read a configuration file in many formats
- Read cli args
- Use secrets from a cloud provider or vault
- Check formating
- Run additional static analysis tools
- Investigate how to get standard unit tests reports
- Investigate how to get standard coverage reports for unit tests
- Investigate how to get standard integration tests reports
- Investigate how to get standard coverage reports for integration tests