SQLx is an async, pure Rust SQL crate featuring compile-time checked queries without a DSL.
axum is a web application framework that focuses on ergonomics and modularity.
tokio - serde - dotenv - bcrypt - uuid
POSTGRES_HOST=<YOUR PG HOST>
POSTGRES_PORT=<YOUR PG PORT>
POSTGRES_USER=<YOUR PG USER>
POSTGRES_PASSWORD=<YOUR PG PASSWORD>
POSTGRES_DB=<YOUR PG DATABASE NAME>
DATABASE_URL=<YOUR PG DATABASE URL>
PGADMIN_DEFAULT_EMAIL=<YOUR PG EMAIL>
PGADMIN_DEFAULT_PASSWORD=<YOUR PG PASSWORD>
SIGNED_JAR_KEY=<SIGNED JAR KEY>
Run cargo install sqlx-cli to install it.
Run sqlx database create to create a new database using the params given on .env.
Use sqlx migrate add <name> to add a new .down.sql and .down.sql migration files.
To run a your migrations use the command sqlx migrate run.
- Models are located in the
src/modelsfolder. - Models have multiple structs that aid on defining the JSON body of a certain request or the return of a query.
- Model structs that are supposed to be used in a JSON body derive:
#[derive(Debug, Deserialize, Serialize)] - Model structs that are used on queries derive:
#[derive(Debug, Deserialize, Serialize, Clone)]
- Handler are located in the
src/handlersfolder. - Handlers are supposed to just call queries.
- Routes are located in the
src/routesfolder. - Routes should appoint directly to an handler method, for example:
route("/users", post(user::create))
- Config are located in the
src/configfolder. - Contains the configuration for the App's Database, App state and Router
- Utils are located in the
src/utilsfolder.
- Structs are located in the
src/structsfolder. - Unlike model structs, the structs located here are meant for the internal functions of the app.