2023-07-29 01:46:24 +00:00
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
use collab_plugins::cloud_storage::RemoteCollabStorage;
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
|
|
|
use flowy_database_deps::cloud::DatabaseCloudService;
|
|
|
|
use flowy_folder_deps::cloud::FolderCloudService;
|
|
|
|
use flowy_server::supabase::api::{
|
2023-08-05 07:02:05 +00:00
|
|
|
RESTfulPostgresServer, RESTfulSupabaseUserAuthServiceImpl, SupabaseCollabStorageImpl,
|
|
|
|
SupabaseDatabaseServiceImpl, SupabaseFolderServiceImpl, SupabaseServerServiceImpl,
|
2023-07-29 01:46:24 +00:00
|
|
|
};
|
|
|
|
use flowy_server::supabase::define::{USER_EMAIL, USER_UUID};
|
|
|
|
use flowy_server_config::supabase_config::SupabaseConfiguration;
|
|
|
|
use flowy_user_deps::cloud::UserService;
|
|
|
|
|
|
|
|
use crate::setup_log;
|
|
|
|
|
|
|
|
pub fn get_supabase_config() -> Option<SupabaseConfiguration> {
|
|
|
|
dotenv::from_filename("./.env.test").ok()?;
|
|
|
|
setup_log();
|
|
|
|
SupabaseConfiguration::from_env().ok()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn collab_service() -> Arc<dyn RemoteCollabStorage> {
|
|
|
|
let config = SupabaseConfiguration::from_env().unwrap();
|
|
|
|
let server = Arc::new(RESTfulPostgresServer::new(config));
|
2023-08-05 07:02:05 +00:00
|
|
|
Arc::new(SupabaseCollabStorageImpl::new(
|
2023-07-29 01:46:24 +00:00
|
|
|
SupabaseServerServiceImpl::new(server),
|
2023-08-12 09:36:31 +00:00
|
|
|
None,
|
2023-07-29 01:46:24 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn database_service() -> Arc<dyn DatabaseCloudService> {
|
|
|
|
let config = SupabaseConfiguration::from_env().unwrap();
|
|
|
|
let server = Arc::new(RESTfulPostgresServer::new(config));
|
2023-08-05 07:02:05 +00:00
|
|
|
Arc::new(SupabaseDatabaseServiceImpl::new(
|
2023-07-29 01:46:24 +00:00
|
|
|
SupabaseServerServiceImpl::new(server),
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn user_auth_service() -> Arc<dyn UserService> {
|
|
|
|
let config = SupabaseConfiguration::from_env().unwrap();
|
|
|
|
let server = Arc::new(RESTfulPostgresServer::new(config));
|
|
|
|
Arc::new(RESTfulSupabaseUserAuthServiceImpl::new(
|
|
|
|
SupabaseServerServiceImpl::new(server),
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn folder_service() -> Arc<dyn FolderCloudService> {
|
|
|
|
let config = SupabaseConfiguration::from_env().unwrap();
|
|
|
|
let server = Arc::new(RESTfulPostgresServer::new(config));
|
2023-08-05 07:02:05 +00:00
|
|
|
Arc::new(SupabaseFolderServiceImpl::new(
|
2023-07-29 01:46:24 +00:00
|
|
|
SupabaseServerServiceImpl::new(server),
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn sign_up_param(uuid: String) -> HashMap<String, String> {
|
|
|
|
let mut params = HashMap::new();
|
|
|
|
params.insert(USER_UUID.to_string(), uuid);
|
|
|
|
params.insert(
|
|
|
|
USER_EMAIL.to_string(),
|
|
|
|
format!("{}@test.com", Uuid::new_v4()),
|
|
|
|
);
|
|
|
|
params
|
|
|
|
}
|