2025-11-29 14:10:05 -07:00
|
|
|
mod api;
|
2025-12-20 18:19:08 -07:00
|
|
|
mod auth;
|
2026-01-30 14:05:07 -07:00
|
|
|
// mod config;
|
2025-12-13 13:29:17 -07:00
|
|
|
pub mod logger;
|
2025-12-03 10:15:20 -07:00
|
|
|
mod server;
|
2025-12-17 16:40:34 -07:00
|
|
|
|
2025-12-03 10:15:20 -07:00
|
|
|
pub use server::Server;
|
|
|
|
|
|
2025-12-20 18:19:08 -07:00
|
|
|
use static_init::dynamic;
|
|
|
|
|
|
2025-12-03 10:15:20 -07:00
|
|
|
#[static_init::dynamic]
|
|
|
|
|
pub static DATABASE_TREES: Vec<&'static str> = vec!["users"];
|
|
|
|
|
|
|
|
|
|
#[static_init::dynamic]
|
|
|
|
|
pub static DEFAULT_HOST: String = "localhost".to_string();
|
|
|
|
|
#[static_init::dynamic]
|
|
|
|
|
pub static DATABASE_NAME: String = "database".to_string();
|
|
|
|
|
|
2025-12-17 17:43:08 -07:00
|
|
|
#[static_init::dynamic]
|
2025-12-21 00:35:28 -07:00
|
|
|
pub static SERVER_CONFIG: unshell_manager::PayloadConfig = unshell_manager::PayloadConfig {
|
2025-12-17 17:43:08 -07:00
|
|
|
id: "Server",
|
|
|
|
|
components: Vec::new(),
|
|
|
|
|
runtime_config: Vec::new(),
|
|
|
|
|
};
|
2025-12-20 18:19:08 -07:00
|
|
|
|
|
|
|
|
// Constants for server config
|
|
|
|
|
pub use api::start_api;
|
|
|
|
|
use chrono::Duration;
|
|
|
|
|
use jsonwebtoken::{DecodingKey, EncodingKey};
|
|
|
|
|
|
|
|
|
|
static EXPIRE_DURATION: Duration = Duration::hours(12);
|
|
|
|
|
|
|
|
|
|
#[dynamic]
|
2026-01-27 15:37:19 -07:00
|
|
|
|
|
|
|
|
static JWT_SECRET: String = {
|
|
|
|
|
if let Ok(env_secret) = std::env::var("JWT_SECRET") {
|
|
|
|
|
env_secret
|
|
|
|
|
} else {
|
|
|
|
|
println!(
|
|
|
|
|
r#"
|
|
|
|
|
##############
|
|
|
|
|
# WARNING: You are using the default JWT secret, used for creating user sessions
|
|
|
|
|
# With this default key, anyone can login as any user.
|
|
|
|
|
##############"#
|
|
|
|
|
);
|
|
|
|
|
"DEFAULT_SECRET".to_string()
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// std::env::var("JWT_SECRET").unwrap_or(|| -> String {
|
|
|
|
|
// return "TEST".to_string();
|
|
|
|
|
// }());
|
2025-12-20 18:19:08 -07:00
|
|
|
|
|
|
|
|
#[dynamic]
|
|
|
|
|
static JWT_ENCODING_KEY: EncodingKey = EncodingKey::from_secret(JWT_SECRET.as_bytes());
|
|
|
|
|
#[dynamic]
|
|
|
|
|
static JWT_DECODING_KEY: DecodingKey = DecodingKey::from_secret(JWT_SECRET.as_bytes());
|