Skip to content

Commit 2f181d0

Browse files
committed
Update dependencies and MySQL test image
Bump compatible direct dependencies, remove unmaintained CLI/test dependencies, migrate examples to current APIs, and switch the MySQL 8 compose service to mysql:8 for local test compatibility.
1 parent 718d289 commit 2f181d0

39 files changed

Lines changed: 1267 additions & 1267 deletions

File tree

‎Cargo.lock‎

Lines changed: 1114 additions & 1123 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ paste = "1.0.6"
173173
serde = { version = "1.0.132", features = ["derive"] }
174174
serde_json = "1.0.73"
175175
url = "2.2.2"
176-
rand = "0.8"
177-
rand_xoshiro = "0.7.0"
176+
rand = "0.10"
177+
rand_xoshiro = "0.8"
178178
hex = "0.4.3"
179-
tempdir = "0.3.7"
179+
tempfile = "3"
180180
either = "1.6.1"
181181
# Needed to test SQLCipher
182182
libsqlite3-sys = { version = "0", features = [

‎examples/mysql/todos/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ workspace = "../../../"
99
anyhow = "1.0"
1010
futures = "0.3"
1111
sqlx = { package = "sqlx-oldapi", path = "../../../", features = [ "mysql", "runtime-tokio-native-tls" ] }
12-
structopt = "0.3"
12+
clap = { version = "4.5", features = ["derive"] }
1313
tokio = { version = "1.20.0", features = ["macros"]}

‎examples/mysql/todos/src/main.rs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1+
extern crate sqlx as sqlx_oldapi;
2+
3+
use clap::{Parser, Subcommand};
14
use sqlx::mysql::MySqlPool;
25
use std::env;
3-
use structopt::StructOpt;
46

5-
#[derive(StructOpt)]
7+
#[derive(Parser)]
68
struct Args {
7-
#[structopt(subcommand)]
9+
#[command(subcommand)]
810
cmd: Option<Command>,
911
}
1012

11-
#[derive(StructOpt)]
13+
#[derive(Subcommand)]
1214
enum Command {
1315
Add { description: String },
1416
Done { id: u64 },
1517
}
1618

1719
#[tokio::main]
1820
async fn main() -> anyhow::Result<()> {
19-
let args = Args::from_args_safe()?;
21+
let args = Args::try_parse()?;
2022
let pool = MySqlPool::connect(&env::var("DATABASE_URL")?).await?;
2123

2224
match args.cmd {

‎examples/postgres/axum-social-with-tests/Cargo.toml‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ publish = false
88

99
[dependencies]
1010
# Primary crates
11-
axum = { version = "0.5.13", features = ["macros"] }
11+
axum = { version = "0.8", features = ["macros"] }
1212
sqlx = { package = "sqlx-oldapi", version = "0.6.53", path = "../../../", features = ["runtime-tokio-rustls", "postgres", "time", "uuid"] }
13-
tokio = { version = "1.20.1", features = ["rt-multi-thread", "macros"] }
13+
tokio = { version = "1.20.1", features = ["rt-multi-thread", "macros", "net"] }
1414

1515
# Important secondary crates
16-
argon2 = "0.4.1"
17-
rand = "0.8"
16+
argon2 = "0.5.3"
17+
rand = "0.10"
1818
regex = "1.6.0"
1919
serde = "1.0.140"
20-
serde_with = { version = "2.0.0", features = ["time_0_3"] }
20+
serde_with = { version = "3.20", features = ["time_0_3"] }
2121
time = "0.3.11"
2222
uuid = { version = "1.1.2", features = ["serde"] }
23-
validator = { version = "0.16.0", features = ["derive"] }
23+
validator = { version = "0.20", features = ["derive"] }
2424

2525
# Auxilliary crates
2626
anyhow = "1.0.58"
2727
dotenvy = "0.15.1"
2828
once_cell = "1.13.0"
29-
thiserror = "1.0.31"
29+
thiserror = "2"
3030
tracing = "0.1.35"
3131

3232
[dev-dependencies]
3333
serde_json = "1.0.82"
34-
tower = "0.4.13"
34+
tower = { version = "0.5", features = ["util"] }

‎examples/postgres/axum-social-with-tests/src/http/mod.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use anyhow::Context;
22
use axum::{Extension, Router};
33
use sqlx::PgPool;
4+
use tokio::net::TcpListener;
45

56
mod error;
67

@@ -19,8 +20,11 @@ pub fn app(db: PgPool) -> Router {
1920
}
2021

2122
pub async fn serve(db: PgPool) -> anyhow::Result<()> {
22-
axum::Server::bind(&"0.0.0.0:8080".parse().unwrap())
23-
.serve(app(db).into_make_service())
23+
let listener = TcpListener::bind("0.0.0.0:8080")
24+
.await
25+
.context("failed to bind API listener")?;
26+
27+
axum::serve(listener, app(db))
2428
.await
2529
.context("failed to serve API")
2630
}

‎examples/postgres/axum-social-with-tests/src/http/post/comment.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use uuid::Uuid;
1717

1818
pub fn router() -> Router {
1919
Router::new().route(
20-
"/v1/post/:postId/comment",
20+
"/v1/post/{postId}/comment",
2121
get(get_post_comments).post(create_post_comment),
2222
)
2323
}

‎examples/postgres/axum-social-with-tests/src/http/user.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use axum::http::StatusCode;
22
use axum::{routing::post, Extension, Json, Router};
33
use once_cell::sync::Lazy;
4-
use rand::Rng;
54
use regex::Regex;
65
use std::time::Duration;
76

@@ -25,7 +24,7 @@ static USERNAME_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"^[0-9A-Za-z_]+$")
2524
#[derive(Deserialize, Validate)]
2625
#[serde(rename_all = "camelCase")]
2726
pub struct UserAuth {
28-
#[validate(length(min = 3, max = 16), regex = "USERNAME_REGEX")]
27+
#[validate(length(min = 3, max = 16), regex(path = *USERNAME_REGEX))]
2928
username: String,
3029
#[validate(length(min = 8, max = 32))]
3130
password: String,
@@ -85,7 +84,7 @@ impl UserAuth {
8584

8685
// Sleep a random amount of time to avoid leaking existence of a user in timing.
8786
let sleep_duration =
88-
rand::thread_rng().gen_range(Duration::from_millis(100)..=Duration::from_millis(500));
87+
rand::random_range(Duration::from_millis(100)..=Duration::from_millis(500));
8988
tokio::time::sleep(sleep_duration).await;
9089

9190
Err(Error::UnprocessableEntity(
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
extern crate sqlx as sqlx_oldapi;
2+
13
pub mod http;
24

35
mod password;

‎examples/postgres/axum-social-with-tests/src/main.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
extern crate sqlx as sqlx_oldapi;
2+
13
use anyhow::Context;
24
use sqlx::postgres::PgPoolOptions;
35

0 commit comments

Comments
 (0)