summaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-03-27 21:24:42 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-03-27 21:24:42 -0500
commitb263c6637ce8b7c83e4d01d1ef2e90e195a155fb (patch)
tree407b4da8e86407db24318442aea211e1cabbc90d /src/state.rs
parente3cb1a5f3c57b3c857107f735651268e0a78692b (diff)
feat: add login route and improved tests
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/state.rs b/src/state.rs
index 614688b..508aaa4 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -1,19 +1,18 @@
-use sqlx::{postgres::PgPoolOptions, Pool, Postgres};
+use sqlx::{Pool, Postgres};
#[derive(Debug)]
pub struct AppState {
pub pool: Pool<Postgres>,
+ pub jwt_secret: String,
+ pub jwt_max_age: time::Duration,
}
impl AppState {
- pub async fn init(database_uri: &str) -> Result<Self, sqlx::Error> {
- let pool = PgPoolOptions::new()
- .max_connections(10)
- .connect(database_uri)
- .await?;
-
- sqlx::migrate!().run(&pool).await?;
-
- Ok(Self { pool })
+ pub fn new(pool: Pool<Postgres>, jwt_secret: String, jwt_max_age: time::Duration) -> Self {
+ Self {
+ pool,
+ jwt_secret,
+ jwt_max_age,
+ }
}
}