Skip to content

fabienbellanger/actix-sqlx-boilerplate

Repository files navigation

actix-sqlx-boilerplate

A simple Actix-web boilerplate using SQLx

Routes

Documentation

Run

cargo run --bin api

Logs

The project uses tracing for logs.
To format them, the project actix-web-logs-reader which is inspired by Luca Palmieri's Bunyan project.
To install it, just run:

cargo install --git https://github.com/fabienbellanger/actix-web-logs-reader --branch main

Actix-web logs can be formatted like this:

cargo run | actix-web-logs-reader

Cargo watch

cargo-watch repository: Github Usage:

cargo watch -x 'run --bin api'

Benchmark

Use Drill

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

SQLx

sqlx repository: Github

TODO: Upgrade to sqlx 0.5 when actix-web upgraded in 4.0

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

Revet migrations:

sqlx migrate revert

Documentation

Run:

cargo doc --open --no-deps

Run with private items:

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

TODO list

  • Implement JWT authentication
  • Add /register route
  • Mieux gérer la route /login quand le user est supprimé
  • Implement FromRequest trait to retrieve the request ID in an handler
  • Add SQLx auto-migrate. Done, but does not work with sqlx 0.4:
    Error: 
    0: while executing migrations: error returned from database: 1062 (23000): Duplicate entry '20210316155055' for key 'PRIMARY'
    1: error returned from database: 1062 (23000): Duplicate entry '20210316155055' for key 'PRIMARY'
    
  • Improve validator response error
  • Add streaming with a large sqlx request
  • Add unit tests
  • Improve WebSocket routes

Help

About

A simple Actix-web boilerplate using SQLx

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published