2023-05-23 15:55:21 +00:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
2023-10-02 09:22:22 +00:00
|
|
|
use flowy_server_config::af_cloud_config::AFCloudConfiguration;
|
2023-07-14 05:37:13 +00:00
|
|
|
use flowy_server_config::supabase_config::SupabaseConfiguration;
|
2023-11-20 12:54:47 +00:00
|
|
|
use flowy_server_config::AuthenticatorType;
|
2023-07-05 12:57:09 +00:00
|
|
|
|
2023-05-23 15:55:21 +00:00
|
|
|
#[derive(Deserialize, Debug)]
|
2023-11-20 12:54:47 +00:00
|
|
|
pub struct AppFlowyDartConfiguration {
|
|
|
|
/// This path will be used to store the user data
|
|
|
|
pub custom_app_path: String,
|
|
|
|
pub origin_app_path: String,
|
|
|
|
pub device_id: String,
|
|
|
|
pub cloud_type: AuthenticatorType,
|
|
|
|
pub(crate) supabase_config: SupabaseConfiguration,
|
|
|
|
pub(crate) appflowy_cloud_config: AFCloudConfiguration,
|
2023-05-23 15:55:21 +00:00
|
|
|
}
|
|
|
|
|
2023-11-20 12:54:47 +00:00
|
|
|
impl AppFlowyDartConfiguration {
|
|
|
|
pub fn from_str(s: &str) -> Self {
|
|
|
|
serde_json::from_str::<AppFlowyDartConfiguration>(s).unwrap()
|
2023-11-17 07:38:56 +00:00
|
|
|
}
|
|
|
|
|
2023-08-17 15:46:39 +00:00
|
|
|
/// Parse the environment variable from the frontend application. The frontend will
|
|
|
|
/// pass the environment variable as a json string after launching.
|
2023-11-12 10:00:07 +00:00
|
|
|
pub fn write_env_from(env_str: &str) {
|
2023-11-20 12:54:47 +00:00
|
|
|
let configuration = Self::from_str(env_str);
|
|
|
|
configuration.cloud_type.write_env();
|
2023-11-24 03:54:47 +00:00
|
|
|
configuration.appflowy_cloud_config.write_env();
|
|
|
|
configuration.supabase_config.write_env();
|
2023-05-23 15:55:21 +00:00
|
|
|
}
|
|
|
|
}
|