summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2025-01-24 12:00:24 +0100
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2025-01-24 12:00:24 +0100
commitc2786c4b9d704128da80ce4ed6513b9f5507b680 (patch)
treefe17ca91b195a7b55b4b30f343a5a6eea95a755e /src/main.rs
parent8c4de2ddac066a072f376e9f30409b114aa9978c (diff)
polishingHEADmaster
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 9c96c4b..0151c47 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,6 +5,7 @@ mod extractors;
use actix_web::{web, App, HttpServer};
use dotenv::dotenv;
+use std::env;
use std::sync::Arc;
#[derive(Clone)]
@@ -21,17 +22,25 @@ async fn main() -> std::io::Result<()> {
env_logger::init();
dotenv().ok();
+ /* create database wrapper (reference: acsim) */
let db_raw = match database::DatabaseWrapper::new().await {
Ok(res) => res,
Err(_) => panic!("Error creating database wrapper"),
};
-
let db = Arc::new(db_raw);
+
+ /* get jwt secret from env */
+ let jwt_secret = env::var("SECRET")
+ .expect("environment variable SECRET is *probably not setted up!!")
+ .to_string();
+
+ /* application data struct */
let app_state = AppState {
database: db,
- secret: "secret".to_owned(),
+ secret: jwt_secret,
};
+ /* main server setup */
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(app_state.clone()))
@@ -44,6 +53,7 @@ async fn main() -> std::io::Result<()> {
.await
}
+/* main page*/
async fn root() -> String {
String::from("Server is up and running")
}