mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-03-14 15:29:06 +00:00
37 lines
1.1 KiB
Rust
37 lines
1.1 KiB
Rust
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<String> = OnceLock::new();
|
|
|
|
/// The config directory where the application stores its configuration.
|
|
pub static CONFIG_DIRECTORY: OnceLock<String> = 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()
|
|
} |