Files
unshell/unshell-server/src/lib.rs
T

58 lines
1.4 KiB
Rust
Raw Normal View History

2025-11-29 14:10:05 -07:00
mod api;
mod auth;
2026-01-30 14:05:07 -07:00
// mod config;
2025-12-13 13:29:17 -07:00
pub mod logger;
mod server;
2025-12-17 16:40:34 -07:00
pub use server::Server;
use static_init::dynamic;
#[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(),
};
// Constants for server config
pub use api::start_api;
use chrono::Duration;
use jsonwebtoken::{DecodingKey, EncodingKey};
static EXPIRE_DURATION: Duration = Duration::hours(12);
#[dynamic]
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();
// }());
#[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());