Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A fullstack RealWorld implementation using rust, axum, sqlx, and yew!

License

NotificationsYou must be signed in to change notification settings

JoeyMckenzie/realworld-rust-axum-sqlx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MITCICoverageCodecov

realworld_logo

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 maketest

Again, the target above will run all included unit tests found in the project. To run the frontend projectusingtrunk:

cargo make web

Project Structure

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.rs file to drive startup and wire librarydependencies together
  • crates/conduit-web - (in progress) web frontend project utilizingyew
  • crates/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 repository
  • crates/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 up
  • integrations - contains the RealWorld Postman test scripts and collection
  • cypress - 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

Why is therepackage.json file?

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-verify

Using Docker

The 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 run

Thedev 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.

TODO

There's a lot more unit tests to write...

About

A fullstack RealWorld implementation using rust, axum, sqlx, and yew!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp