Skip to content

Commit

Permalink
feature: support db migration and user model
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrchen committed Apr 26, 2024
1 parent 9c00b38 commit 935fcf8
Show file tree
Hide file tree
Showing 9 changed files with 410 additions and 12 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=postgres://postgres:postgres@localhost/chat
220 changes: 220 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ axum = { version = "0.7.5", features = [
] }
serde = { version = "1.0.198", features = ["derive"] }
serde_yaml = "0.9.34"
sqlx = { version = "0.7.4", features = ["postgres", "runtime-tokio-rustls"] }
sqlx = { version = "0.7.4", features = [
"chrono",
"postgres",
"runtime-tokio",
"tls-rustls",
] }
thiserror = "1.0.59"
tokio = { version = "1.37.0", features = ["rt", "rt-multi-thread", "macros"] }
tracing = "0.1.40"
Expand Down
5 changes: 5 additions & 0 deletions chat_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ edition = "2021"

[dependencies]
anyhow = { workspace = true }
argon2 = { version = "0.5.3", features = ["std"] }
axum = { workspace = true }
chrono = { version = "0.4.38", features = ["serde"] }
serde = { workspace = true }
serde_yaml = { workspace = true }
sqlx = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }

[dev-dependencies]
sqlx-db-tester = "0.4.0"
10 changes: 10 additions & 0 deletions chat_server/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use thiserror::Error;

#[derive(Error, Debug)]
pub enum AppError {
#[error("sql error: {0}")]
SqlxError(#[from] sqlx::Error),

#[error("password hash error: {0}")]
PasswordHashError(#[from] argon2::password_hash::Error),
}
Loading

0 comments on commit 935fcf8

Please sign in to comment.