env and docker fixes

This commit is contained in:
2025-11-04 12:54:22 +01:00
parent 67302965d8
commit 359f7a4ad8
16 changed files with 156 additions and 34 deletions

View File

@@ -19,14 +19,15 @@ use crate::utils::db_pool::{HotelPool,AppState};
use routes::create_router;
use crate::utils::auth::JwtKeys;
use std::env;
use dotenvy::dotenv;
#[tokio::main(flavor = "multi_thread", worker_threads = 8)]
async fn main() -> std::io::Result<()> {
dotenv().ok();
let hotel_pools = HotelPool::new();
let logs_manager = SqliteConnectionManager::file("db/auth.sqlite");
@@ -42,7 +43,12 @@ async fn main() -> std::io::Result<()> {
//jwt_secret: "your_jwt_secret_key s".to_string(), // better: load from env var
};
let jwt_secret = "your_jwt_secret_key".to_string();
//let jwt_secret = "your_jwt_secret_key".to_string();
let jwt_secret = env::var("JWT_SECRET")
.expect("JWT_SECRET must be set")
.to_string();
let jwt_keys = JwtKeys {
encoding: EncodingKey::from_secret(jwt_secret.as_ref()),
decoding: DecodingKey::from_secret(jwt_secret.as_ref()),
@@ -53,7 +59,7 @@ async fn main() -> std::io::Result<()> {
let app = create_router(state)
.layer(Extension(jwt_keys));
let listener = TcpListener::bind("0.0.0.0:3000").await?;
let listener = TcpListener::bind("0.0.0.0:8080").await?;
serve(listener, app).into_future().await?;
Ok(())
}