Skip to content

The northwind application with the clean architecture approach powered by Rust

License

Notifications You must be signed in to change notification settings

thangchung/northwind-rs

Repository files navigation

northwind-rs

The Northwind application powered by Rust (actix-web, sqlx, jwt...)

Generated from actix-sqlx-boilerplate

Give a star ⭐

If you're using this repository for your samples, workshop, your project or whatever, please give a star ⭐. Thank you very much 👍

Up and running

Run server

$ docker-compose up
$ cargo run --bin northwind-actix

Then play around with restclient.http

SQLx

sqlx repository: Github

sqlx-cli

sqlx-cli repository: Github

$ cargo install sqlx-cli --no-default-features --features postgres

Offline mode

On windows 10

Make sure that you have docker-compose up running with at least postgresdb

$ cargo clean
$ cmd /c "set SQLX_OFFLINE=true && cargo sqlx prepare -- --manifest-path apps/actix/Cargo.toml --bin northwind-actix"

Make sure, we have sqlx-data.json updated. Then, we can build the buildpack below

The issue couldn't run cargo sqlx cli successfully at launchbadge/sqlx#788

Migrations

To create a migration:

$ sqlx migrate add -r <name>

Run migrations:

$ sqlx migrate run

Revet migrations:

$ sqlx migrate revert

Cargo watch

Usage:

$ cargo watch -x 'run --bin api'

Benchmark

Use Drill

$ drill --benchmark drill.yml --stats --quiet

Documentation

Run:

$ cargo doc --open --no-deps

Run with private items:

$ cargo doc --open --no-deps --document-private-items

Build Docker image with CNCF Buildpacks

$ pack build vietnamdevsgroup/northwind-rs -e SQLX_OFFLINE=true -e BP_CARGO_INSTALL_ARGS="--path=./apps/actix" 
-b docker.io/paketocommunity/rust

Un-comment section northwindrs in docker-compose.yaml file, then run:

$ docker-compose up

Troubleshooting

Inspect docker image

$ docker run -it --entrypoint /bin/bash vietnamdevsgroup/northwind-rs

Dive to see what inside docker image

$ docker pull wagoodman/dive:latest
$ docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive:latest vietnamdevsgroup/northwind-rs

Releases

No releases published

Packages

No packages published

Languages