Demo application for the RATH stack (Rust + Axum + Turso + HTMX).
App runs at https://rust-api-plus-htmx.fly.dev. It can take up to 20 seconds to respond for the first request, because the Turso db and Fly.io app automaticly scale down to 0.
- Axum - web API framework for Rust
- Turso - Sqlite based database
- HTMX - HTML-first web library
- Tailwind CSS + daisyui - class based CSS
- Minijinja - templating engine for Rust
- Fly.io - hosting in Docker containers
First, create a Turso account and get the DB url + Auth token.
Setting up:
mv .env.example .env
# Edit .env file and set the correct values
cd static
npm install
npm install -g tailwindcss
# Copies js files from node_modules into the /static/dist folder
bash init.sh
Running the app:
cargo run
# Or run when any non-static file (-i) changes and clear console (-c)
cargo watch -c -x run -i /static
# Run tailwind in another window
cd static
npm run tailwind
You can execute prepush.sh
to fix lint and format.
Run lint
# Check
cargo clippy -- -A clippy::needless_return
# Fix
cargo clippy --allow-dirty --fix -- -A clippy::needless_return
Run formatter
cargo +nightly fmt -- src/routes.rs
Fly commands
fly machine start
fly machine stop
# make sure you have a .env.prod file before deploying!
fly deploy # Deploy using remote runner
sudo fly deploy --local-only # Deploy using local docker runner