- Notifications
You must be signed in to change notification settings - Fork20
A fullstack RealWorld implementation using rust, axum, sqlx, and yew!
License
JoeyMckenzie/realworld-rust-axum-sqlx
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A fullstack implementation of the RealWorld project usingRust,axum,sqlx, andyew.
To get started, installDocker andcargo-makeon your local machine (Windows users may want to use WSL for ease of development), then clone/fork the repository. Onceyou have the projectlocal to your machine, create an.env file local to workspace with valid values (you can use the defaults as well).
cp .env.example .env
Next, create and start our Docker containers:
cargo make docker
Once the application containers have started, verify all integration tests pass:
cargo make integration
The above target will run the included Postman suite of tests designed by the authors of the RealWorld project.Once the tests have completed, verify all unit tests are passing as well:
cargo maketestAgain, the target above will run all included unit tests found in the project. To run the frontend projectusingtrunk:
cargo make web
This project is more or less a Rust playground for myself and others to learn Rust, axum, and sqlx.We utilizecargo workspaces to help encapsulateproject-specific logic/domains, with a rough organization strategy as follows:
crates/conduit-bin- API entry point, consisting of a singlemain.rsfile to drive startup and wire librarydependencies togethercrates/conduit-web- (in progress) web frontend project utilizingyewcrates/conduit-api- web API project housing axum specific setup, endpoints, routing, request/response marshalling,etc.crates/conduit-core- core logic and contract definitions between domains, services, and repositorycrates/conduit-domain- a simple project to house PORS (plain old rust structs) used for API request and responses,services, etc.crates/conduit-infrastructure- a project adapter containing implementations of the core business logics definitionsfromhigher upintegrations- contains the RealWorld Postman test scripts and collectioncypress- contains the e2e tests used to test the frontend project (crates/conduit-web)deploy- contains all Docker Compose files used for building the project containers.husky- contains husky git hooks
I usehusky for pre-commit hooksandlint-stagedto format staged files to keep committed code well formatted. While there are a few other options for includingpre-commit hooksinto a Rust project, and certainly those that are more appropriate for Rust projects, I wanted to leave open theopportunityof bringing on a TS-based frontend sometime in the future to have the true RealWorld fullstack experience. Thepre-commit hooks will format, lint, and test all code so that each commit ensure that tests are passing and code doesnot contain any obvious errors.
To bypass the included hooks, simply pass a--no-verify flag while committing code
git commit -m"feat(core): add some amazing unit tests" --no-verifyThe project utilizes Docker containers for Postgres and Prometheus metrics, as well as containers for the API and frontend. For example, when starting theapplication withcargo make docker, navigating tolocalhost:9090 will bring you to the Prometheus metrics page.From there, running integration tests withcargo make integration to simulate traffic to the API allows one to observethevariousmetrics that are recorded in the service layer: request count, request latency, and histograms of service requestintervals.
To start the API outside the Docker context, run:
cargo make dev# or cargo runThedev tasks takes on thepostgres task as a dependency, so your database container will start automatically.
If you're starting the application for the first time, it will attempt to seed a bit of data that is also used fortesting.
There's a lot more unit tests to write...
About
A fullstack RealWorld implementation using rust, axum, sqlx, and yew!
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
