mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-11 17:27:21 +00:00
Refactored runtime (#192)
This commit is contained in:
1 parent
58d7478f3a
commit
d0a366258a
13 files changed
+1254
-1050
No files matched your search
@@ -0,0 +1,37 @@
|
||||
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()
|
||||
}
|
||||
Reference in new issue
Block a user