use std::sync::OnceLock; use rocket::get; use crate::api_token::APIToken; /// The data directory where the application stores its data. pub static DATA_DIRECTORY: OnceLock = OnceLock::new(); /// The config directory where the application stores its configuration. pub static CONFIG_DIRECTORY: OnceLock = OnceLock::new(); /// Returns the config directory. #[get("/system/directories/config")] pub fn get_config_directory(_token: APIToken) -> String { match CONFIG_DIRECTORY.get() { Some(config_directory) => config_directory.clone(), None => String::from(""), } } /// Returns the data directory. #[get("/system/directories/data")] pub fn get_data_directory(_token: APIToken) -> String { match DATA_DIRECTORY.get() { Some(data_directory) => data_directory.clone(), None => String::from(""), } } /// Returns true if the application is running in development mode. pub fn is_dev() -> bool { cfg!(debug_assertions) } /// Returns true if the application is running in production mode. pub fn is_prod() -> bool { !is_dev() }