summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..dc132b8
--- /dev/null
+++ b/src/config.rs
@@ -0,0 +1,31 @@
+#[derive(Debug, Default, Clone)]
+pub struct Config {
+ pub database_url: String,
+ pub jwt_secret: String,
+ pub jwt_expires_in: String,
+ pub jwt_maxage: i32,
+}
+
+impl Config {
+ pub fn init() -> Config {
+ let mut config = Config::default();
+
+ if let Ok(database_url) = std::env::var("DATABASE_URL") {
+ config.database_url = database_url;
+ };
+
+ if let Ok(jwt_secret) = std::env::var("JWT_SECRET") {
+ config.jwt_secret = jwt_secret;
+ };
+
+ if let Ok(jwt_expires_in) = std::env::var("JWT_EXPIRED_IN") {
+ config.jwt_expires_in = jwt_expires_in;
+ };
+
+ if let Ok(jwt_maxage) = std::env::var("JWT_MAXAGE") {
+ config.jwt_maxage = jwt_maxage.parse::<i32>().unwrap();
+ };
+
+ config
+ }
+}