summaryrefslogtreecommitdiffstats
path: root/src/models
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-09-12 13:30:19 +0000
committerSanto Cariotti <santo@dcariotti.me>2022-09-12 13:30:19 +0000
commitaf3f5430a0b0f1834228b28fd89848959512e718 (patch)
tree27e843c147b92bf09893012f323ddaf54f5eb0a5 /src/models
parent385102a5763f667d53a9d8ed2052ccb8c791bc91 (diff)
Use configuration for environment variables
Diffstat (limited to 'src/models')
-rw-r--r--src/models/auth.rs2
-rw-r--r--src/models/model.rs6
-rw-r--r--src/models/user.rs6
3 files changed, 7 insertions, 7 deletions
diff --git a/src/models/auth.rs b/src/models/auth.rs
index 36a0175..8a70244 100644
--- a/src/models/auth.rs
+++ b/src/models/auth.rs
@@ -40,7 +40,7 @@ pub struct LoginCredentials {
}
static KEYS: Lazy<Keys> = Lazy::new(|| {
- let secret = std::env::var("JWT_SECRET").expect("JWT_SECRET must be set");
+ let secret = &crate::config::CONFIG.jwt_secret;
Keys::new(secret.as_bytes())
});
diff --git a/src/models/model.rs b/src/models/model.rs
index 5b47f5c..f686192 100644
--- a/src/models/model.rs
+++ b/src/models/model.rs
@@ -1,4 +1,4 @@
-use crate::config::PAGE_LIMIT;
+use crate::config::CONFIG;
use crate::db::get_client;
use crate::errors::AppError;
@@ -163,8 +163,8 @@ impl Model {
GROUP BY models.id, users.id
LIMIT $1 OFFSET $2
"#,
- PAGE_LIMIT,
- PAGE_LIMIT * page
+ CONFIG.page_limit,
+ CONFIG.page_limit * page
)
.fetch_all(pool)
.await?;
diff --git a/src/models/user.rs b/src/models/user.rs
index 22bd130..55abc97 100644
--- a/src/models/user.rs
+++ b/src/models/user.rs
@@ -1,4 +1,4 @@
-use crate::config::PAGE_LIMIT;
+use crate::config::CONFIG;
use crate::db::get_client;
use crate::errors::AppError;
@@ -121,8 +121,8 @@ impl User {
r#"SELECT id, email, username, is_staff FROM users
LIMIT $1 OFFSET $2
"#,
- PAGE_LIMIT,
- PAGE_LIMIT * page
+ CONFIG.page_limit,
+ CONFIG.page_limit * page
)
.fetch_all(pool)
.await?;