/axum-boilerplate

Axum web framework boilerplate

Primary LanguageRustMIT LicenseMIT

Axum boilerplate

Build status

Axum Repository framework boilerplate

Axum Doc

Cargo watch

cargo-watch repository: Github

cargo watch -x 'run --bin axum-boilerplate-bin'

Cargo audit

cargo-audit repository: Github

Installation:

cargo install cargo-audit --features=fix

Usage:

cargo audit
cargo audit fix

Unit tests

cargo test -- --test-threads=1

Benchmark

Use Drill

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

SQLx

sqlx repository: Github

sqlx-cli

sqlx-cli repository: Github

Migrations

To create a migration:

sqlx migrate add -r <name>
sqlx migrate add -r create_users_table

Run migrations:

sqlx migrate run

Revert migrations:

sqlx migrate revert

Offline mode

Used for Github Actions or Docker

/!\ Be careful, sqlx and sqlx-cli must be in the same version!

cargo sqlx prepare -- --bin <app name in Cargo.toml>
cargo sqlx prepare -- --lib

Then set env variable SQLX_OFFLINE to true.

For example:

SQLX_OFFLINE=true cargo build

Documentation

Run:

cargo doc --open --no-deps

Run with private items:

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

OpenAPI

OpenAPI documentation using Rapidoc

YAML file: assets/doc/doc_api_v1.yml

URL: <baseURL>/doc/api-v1.html

Docker

Run the server:

make docker

To create the admin user:

make docker-cli-register

TODO:

  • Improve global documentation
  • Improve README.md to explain the boilerplate
  • Add scopes (currently roles) to routes
  • Add password scorer passwords (parameter in .env?)
  • Add more .env parameters in SharedState?
  • Replace config file .env by config.toml or add config.toml?
  • Add WebSocket examples
    • Simple WebSocket example
    • Chat WebSocket example
  • Rate limiter middleware
    • Add documentation
    • Optimize code
    • Add white list from .env
  • Add Docker support