summaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
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,
+ }
}
}