AppFlowy/frontend/rust-lib/flowy-server-config/src/lib.rs
Nathan.fooo b9ecc7ceb6
chore: add custom folder prompt (#3961)
* chore: add custom folder prompt

* chore: zip collab db

* chore: fix test

* chore: add test

* chore: fmt

* chore: fmt

* chore: fmt
2023-11-20 20:54:47 +08:00

38 lines
861 B
Rust

use serde_repr::Deserialize_repr;
pub mod af_cloud_config;
pub mod supabase_config;
pub const CLOUT_TYPE_STR: &str = "APPFLOWY_CLOUD_ENV_CLOUD_TYPE";
#[derive(Deserialize_repr, Debug, Clone)]
#[repr(u8)]
pub enum AuthenticatorType {
Local = 0,
Supabase = 1,
AppFlowyCloud = 2,
}
impl AuthenticatorType {
pub fn write_env(&self) {
let s = self.clone() as u8;
std::env::set_var(CLOUT_TYPE_STR, s.to_string());
}
#[allow(dead_code)]
fn from_str(s: &str) -> Self {
match s {
"0" => AuthenticatorType::Local,
"1" => AuthenticatorType::Supabase,
"2" => AuthenticatorType::AppFlowyCloud,
_ => AuthenticatorType::Local,
}
}
#[allow(dead_code)]
pub fn from_env() -> Self {
let cloud_type_str = std::env::var(CLOUT_TYPE_STR).unwrap_or_default();
AuthenticatorType::from_str(&cloud_type_str)
}
}