mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
[rust]: rm flowy-net
This commit is contained in:
@ -65,7 +65,7 @@ flowy-workspace-infra = { path = "../rust-lib/flowy-workspace-infra" }
|
|||||||
flowy-document-infra = { path = "../rust-lib/flowy-document-infra" }
|
flowy-document-infra = { path = "../rust-lib/flowy-document-infra" }
|
||||||
lib-ws = { path = "../rust-lib/lib-ws" }
|
lib-ws = { path = "../rust-lib/lib-ws" }
|
||||||
lib-ot = { path = "../rust-lib/lib-ot" }
|
lib-ot = { path = "../rust-lib/lib-ot" }
|
||||||
flowy-net = { path = "../rust-lib/flowy-net", features = ["http_server"] }
|
backend-service = { path = "../rust-lib/backend-service", features = ["http_server"] }
|
||||||
|
|
||||||
ormx = { version = "0.7", features = ["postgres"]}
|
ormx = { version = "0.7", features = ["postgres"]}
|
||||||
[dependencies.sqlx]
|
[dependencies.sqlx]
|
||||||
@ -99,7 +99,6 @@ parking_lot = "0.11"
|
|||||||
once_cell = "1.7.2"
|
once_cell = "1.7.2"
|
||||||
linkify = "0.5.0"
|
linkify = "0.5.0"
|
||||||
backend = { path = ".", features = ["flowy_test"]}
|
backend = { path = ".", features = ["flowy_test"]}
|
||||||
backend-api = { path = "../rust-lib/backend-api" }
|
|
||||||
flowy-sdk = { path = "../rust-lib/flowy-sdk", features = ["http_server"] }
|
flowy-sdk = { path = "../rust-lib/flowy-sdk", features = ["http_server"] }
|
||||||
flowy-user = { path = "../rust-lib/flowy-user", features = ["http_server"] }
|
flowy-user = { path = "../rust-lib/flowy-user", features = ["http_server"] }
|
||||||
flowy-document = { path = "../rust-lib/flowy-document", features = ["flowy_test", "http_server"] }
|
flowy-document = { path = "../rust-lib/flowy-document", features = ["flowy_test", "http_server"] }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::config::env::{domain, jwt_secret};
|
use crate::config::env::{domain, jwt_secret};
|
||||||
|
use backend_service::errors::ServerError;
|
||||||
use chrono::{Duration, Local};
|
use chrono::{Duration, Local};
|
||||||
use derive_more::{From, Into};
|
use derive_more::{From, Into};
|
||||||
use flowy_net::errors::ServerError;
|
|
||||||
use jsonwebtoken::{decode, encode, Algorithm, DecodingKey, EncodingKey, Header, Validation};
|
use jsonwebtoken::{decode, encode, Algorithm, DecodingKey, EncodingKey, Header, Validation};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ impl Token {
|
|||||||
|
|
||||||
use crate::service::user::EXPIRED_DURATION_DAYS;
|
use crate::service::user::EXPIRED_DURATION_DAYS;
|
||||||
use actix_web::{dev::Payload, FromRequest, HttpRequest};
|
use actix_web::{dev::Payload, FromRequest, HttpRequest};
|
||||||
use flowy_net::config::HEADER_TOKEN;
|
use backend_service::config::HEADER_TOKEN;
|
||||||
use futures::future::{ready, Ready};
|
use futures::future::{ready, Ready};
|
||||||
|
|
||||||
impl FromRequest for Token {
|
impl FromRequest for Token {
|
||||||
|
@ -9,7 +9,7 @@ use actix_web::{
|
|||||||
|
|
||||||
use crate::config::IGNORE_ROUTES;
|
use crate::config::IGNORE_ROUTES;
|
||||||
use actix_web::{body::AnyBody, dev::MessageBody};
|
use actix_web::{body::AnyBody, dev::MessageBody};
|
||||||
use flowy_net::{config::HEADER_TOKEN, errors::ServerError};
|
use backend_service::{config::HEADER_TOKEN, errors::ServerError};
|
||||||
use futures::future::{ok, LocalBoxFuture, Ready};
|
use futures::future::{ok, LocalBoxFuture, Ready};
|
||||||
use std::{
|
use std::{
|
||||||
convert::TryInto,
|
convert::TryInto,
|
||||||
|
@ -5,8 +5,8 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::service::trash::read_trash_ids;
|
use crate::service::trash::read_trash_ids;
|
||||||
|
use backend_service::errors::{invalid_params, ServerError};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use flowy_net::errors::{invalid_params, ServerError};
|
|
||||||
use flowy_workspace_infra::{
|
use flowy_workspace_infra::{
|
||||||
parser::{
|
parser::{
|
||||||
app::{AppDesc, AppName},
|
app::{AppDesc, AppName},
|
||||||
|
@ -2,7 +2,7 @@ use actix_web::{
|
|||||||
web::{Data, Payload},
|
web::{Data, Payload},
|
||||||
HttpResponse,
|
HttpResponse,
|
||||||
};
|
};
|
||||||
use flowy_net::errors::{invalid_params, ServerError};
|
use backend_service::errors::{invalid_params, ServerError};
|
||||||
use flowy_workspace_infra::protobuf::{AppIdentifier, CreateAppParams, UpdateAppParams};
|
use flowy_workspace_infra::protobuf::{AppIdentifier, CreateAppParams, UpdateAppParams};
|
||||||
use protobuf::Message;
|
use protobuf::Message;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
@ -16,7 +16,7 @@ use crate::service::{
|
|||||||
util::parse_from_payload,
|
util::parse_from_payload,
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use flowy_net::response::FlowyResponse;
|
use backend_service::response::FlowyResponse;
|
||||||
use flowy_workspace_infra::parser::app::{AppDesc, AppName};
|
use flowy_workspace_infra::parser::app::{AppDesc, AppName};
|
||||||
|
|
||||||
pub async fn create_handler(
|
pub async fn create_handler(
|
||||||
|
@ -2,8 +2,8 @@ use crate::{
|
|||||||
entities::workspace::{AppTable, APP_TABLE},
|
entities::workspace::{AppTable, APP_TABLE},
|
||||||
sqlx_ext::SqlBuilder,
|
sqlx_ext::SqlBuilder,
|
||||||
};
|
};
|
||||||
|
use backend_service::errors::{invalid_params, ServerError};
|
||||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||||
use flowy_net::errors::{invalid_params, ServerError};
|
|
||||||
use flowy_workspace_infra::{
|
use flowy_workspace_infra::{
|
||||||
parser::app::AppId,
|
parser::app::AppId,
|
||||||
protobuf::{App, ColorStyle},
|
protobuf::{App, ColorStyle},
|
||||||
|
@ -3,8 +3,8 @@ use crate::{
|
|||||||
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
use backend_service::errors::ServerError;
|
||||||
use flowy_document_infra::protobuf::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams};
|
use flowy_document_infra::protobuf::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams};
|
||||||
use flowy_net::errors::ServerError;
|
|
||||||
use sqlx::{postgres::PgArguments, PgPool, Postgres};
|
use sqlx::{postgres::PgArguments, PgPool, Postgres};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ use crate::service::{
|
|||||||
ws::{WsBizHandler, WsClientData},
|
ws::{WsBizHandler, WsClientData},
|
||||||
};
|
};
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
|
use backend_service::errors::{internal_error, ServerError};
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use flowy_document_infra::protobuf::DocIdentifier;
|
use flowy_document_infra::protobuf::DocIdentifier;
|
||||||
use flowy_net::errors::{internal_error, ServerError};
|
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
|
@ -4,8 +4,8 @@ use crate::service::{
|
|||||||
};
|
};
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use async_stream::stream;
|
use async_stream::stream;
|
||||||
|
use backend_service::errors::{internal_error, Result as DocResult, ServerError};
|
||||||
use flowy_document_infra::protobuf::{Doc, Revision};
|
use flowy_document_infra::protobuf::{Doc, Revision};
|
||||||
use flowy_net::errors::{internal_error, Result as DocResult, ServerError};
|
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use std::sync::{atomic::Ordering::SeqCst, Arc};
|
use std::sync::{atomic::Ordering::SeqCst, Arc};
|
||||||
|
@ -4,13 +4,13 @@ use crate::service::{
|
|||||||
ws::{entities::Socket, WsMessageAdaptor},
|
ws::{entities::Socket, WsMessageAdaptor},
|
||||||
};
|
};
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
|
use backend_service::errors::{internal_error, ServerError};
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use flowy_document_infra::{
|
use flowy_document_infra::{
|
||||||
core::Document,
|
core::Document,
|
||||||
entities::ws::{WsDataType, WsDocumentData},
|
entities::ws::{WsDataType, WsDocumentData},
|
||||||
protobuf::{Doc, RevId, RevType, Revision, RevisionRange, UpdateDocParams},
|
protobuf::{Doc, RevId, RevType, Revision, RevisionRange, UpdateDocParams},
|
||||||
};
|
};
|
||||||
use flowy_net::errors::{internal_error, ServerError};
|
|
||||||
use lib_ot::core::{Delta, OperationTransformable};
|
use lib_ot::core::{Delta, OperationTransformable};
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use protobuf::Message;
|
use protobuf::Message;
|
||||||
|
@ -3,8 +3,8 @@ use crate::service::{
|
|||||||
ws::{entities::Socket, WsUser},
|
ws::{entities::Socket, WsUser},
|
||||||
};
|
};
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
|
use backend_service::errors::{internal_error, Result as DocResult, ServerError};
|
||||||
use flowy_document_infra::protobuf::{Doc, Revision};
|
use flowy_document_infra::protobuf::{Doc, Revision};
|
||||||
use flowy_net::errors::{internal_error, Result as DocResult, ServerError};
|
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::{mpsc, oneshot};
|
use tokio::sync::{mpsc, oneshot};
|
||||||
|
@ -7,8 +7,8 @@ use actix_web::{
|
|||||||
HttpResponse,
|
HttpResponse,
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
use backend_service::{errors::ServerError, response::FlowyResponse};
|
||||||
use flowy_document_infra::protobuf::{CreateDocParams, DocIdentifier, UpdateDocParams};
|
use flowy_document_infra::protobuf::{CreateDocParams, DocIdentifier, UpdateDocParams};
|
||||||
use flowy_net::{errors::ServerError, response::FlowyResponse};
|
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
|
|
||||||
pub async fn create_handler(payload: Payload, pool: Data<PgPool>) -> Result<HttpResponse, ServerError> {
|
pub async fn create_handler(payload: Payload, pool: Data<PgPool>) -> Result<HttpResponse, ServerError> {
|
||||||
|
@ -6,8 +6,8 @@ use crate::service::{
|
|||||||
use actix_rt::task::spawn_blocking;
|
use actix_rt::task::spawn_blocking;
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use async_stream::stream;
|
use async_stream::stream;
|
||||||
|
use backend_service::errors::{internal_error, Result as DocResult, ServerError};
|
||||||
use flowy_document_infra::protobuf::{NewDocUser, Revision, WsDataType, WsDocumentData};
|
use flowy_document_infra::protobuf::{NewDocUser, Revision, WsDataType, WsDocumentData};
|
||||||
use flowy_net::errors::{internal_error, Result as DocResult, ServerError};
|
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -9,7 +9,7 @@ use actix_web::{
|
|||||||
HttpResponse,
|
HttpResponse,
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use flowy_net::{
|
use backend_service::{
|
||||||
errors::{invalid_params, ServerError},
|
errors::{invalid_params, ServerError},
|
||||||
response::FlowyResponse,
|
response::FlowyResponse,
|
||||||
};
|
};
|
||||||
|
@ -8,7 +8,7 @@ use crate::{
|
|||||||
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
||||||
};
|
};
|
||||||
use ::protobuf::ProtobufEnum;
|
use ::protobuf::ProtobufEnum;
|
||||||
use flowy_net::errors::ServerError;
|
use backend_service::errors::ServerError;
|
||||||
use flowy_workspace_infra::protobuf::{RepeatedTrash, Trash, TrashType};
|
use flowy_workspace_infra::protobuf::{RepeatedTrash, Trash, TrashType};
|
||||||
use sqlx::{postgres::PgArguments, Postgres, Row};
|
use sqlx::{postgres::PgArguments, Postgres, Row};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -4,11 +4,11 @@ use crate::{
|
|||||||
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use chrono::Utc;
|
use backend_service::{
|
||||||
use flowy_net::{
|
|
||||||
errors::{invalid_params, ErrorCode, ServerError},
|
errors::{invalid_params, ErrorCode, ServerError},
|
||||||
response::FlowyResponse,
|
response::FlowyResponse,
|
||||||
};
|
};
|
||||||
|
use chrono::Utc;
|
||||||
use flowy_user_infra::{
|
use flowy_user_infra::{
|
||||||
parser::{UserEmail, UserName, UserPassword},
|
parser::{UserEmail, UserName, UserPassword},
|
||||||
protobuf::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserProfile},
|
protobuf::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserProfile},
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::entities::token::{Claim, Token};
|
use crate::entities::token::{Claim, Token};
|
||||||
use actix_web::http::HeaderValue;
|
use actix_web::http::HeaderValue;
|
||||||
|
use backend_service::errors::ServerError;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use flowy_net::errors::ServerError;
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
@ -6,7 +6,7 @@ use actix_web::{
|
|||||||
};
|
};
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
|
|
||||||
use flowy_net::{errors::ServerError, response::FlowyResponse};
|
use backend_service::{errors::ServerError, response::FlowyResponse};
|
||||||
use flowy_user_infra::protobuf::{SignInParams, SignUpParams, UpdateUserParams};
|
use flowy_user_infra::protobuf::{SignInParams, SignUpParams, UpdateUserParams};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -7,9 +7,9 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::service::view::{create_view_with_args, sql_builder::NewViewSqlBuilder};
|
use crate::service::view::{create_view_with_args, sql_builder::NewViewSqlBuilder};
|
||||||
|
use backend_service::errors::ServerError;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use flowy_document_infra::user_default::doc_initial_string;
|
use flowy_document_infra::user_default::doc_initial_string;
|
||||||
use flowy_net::errors::ServerError;
|
|
||||||
use flowy_workspace_infra::protobuf::Workspace;
|
use flowy_workspace_infra::protobuf::Workspace;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
use backend_service::errors::{ErrorCode, ServerError};
|
||||||
use bcrypt::{hash, verify, DEFAULT_COST};
|
use bcrypt::{hash, verify, DEFAULT_COST};
|
||||||
use flowy_net::errors::{ErrorCode, ServerError};
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn uuid() -> String { uuid::Uuid::new_v4().to_string() }
|
pub fn uuid() -> String { uuid::Uuid::new_v4().to_string() }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::config::MAX_PAYLOAD_SIZE;
|
use crate::config::MAX_PAYLOAD_SIZE;
|
||||||
use actix_web::web;
|
use actix_web::web;
|
||||||
use flowy_net::errors::{ErrorCode, ServerError};
|
use backend_service::errors::{ErrorCode, ServerError};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use protobuf::{Message, ProtobufResult};
|
use protobuf::{Message, ProtobufResult};
|
||||||
|
|
||||||
@ -10,9 +10,7 @@ pub async fn parse_from_payload<T: Message>(payload: web::Payload) -> Result<T,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub async fn parse_from_dev_payload<T: Message>(
|
pub async fn parse_from_dev_payload<T: Message>(payload: &mut actix_web::dev::Payload) -> Result<T, ServerError> {
|
||||||
payload: &mut actix_web::dev::Payload,
|
|
||||||
) -> Result<T, ServerError> {
|
|
||||||
let bytes = poll_payload(payload).await?;
|
let bytes = poll_payload(payload).await?;
|
||||||
parse_from_bytes(&bytes)
|
parse_from_bytes(&bytes)
|
||||||
}
|
}
|
||||||
@ -31,9 +29,7 @@ pub fn parse_from_bytes<T: Message>(bytes: &[u8]) -> Result<T, ServerError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn poll_payload(
|
pub async fn poll_payload(payload: &mut actix_web::dev::Payload) -> Result<web::BytesMut, ServerError> {
|
||||||
payload: &mut actix_web::dev::Payload,
|
|
||||||
) -> Result<web::BytesMut, ServerError> {
|
|
||||||
let mut body = web::BytesMut::new();
|
let mut body = web::BytesMut::new();
|
||||||
while let Some(chunk) = payload.next().await {
|
while let Some(chunk) = payload.next().await {
|
||||||
let chunk = chunk.map_err(|err| ServerError::internal().context(err))?;
|
let chunk = chunk.map_err(|err| ServerError::internal().context(err))?;
|
||||||
|
@ -9,7 +9,7 @@ use actix_web::{
|
|||||||
HttpResponse,
|
HttpResponse,
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use flowy_net::{
|
use backend_service::{
|
||||||
errors::{invalid_params, ServerError},
|
errors::{invalid_params, ServerError},
|
||||||
response::FlowyResponse,
|
response::FlowyResponse,
|
||||||
};
|
};
|
||||||
|
@ -2,8 +2,8 @@ use crate::{
|
|||||||
entities::workspace::{ViewTable, VIEW_TABLE},
|
entities::workspace::{ViewTable, VIEW_TABLE},
|
||||||
sqlx_ext::SqlBuilder,
|
sqlx_ext::SqlBuilder,
|
||||||
};
|
};
|
||||||
|
use backend_service::errors::{invalid_params, ServerError};
|
||||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||||
use flowy_net::errors::{invalid_params, ServerError};
|
|
||||||
use flowy_workspace_infra::{
|
use flowy_workspace_infra::{
|
||||||
parser::view::ViewId,
|
parser::view::ViewId,
|
||||||
protobuf::{View, ViewType},
|
protobuf::{View, ViewType},
|
||||||
|
@ -8,9 +8,9 @@ use crate::{
|
|||||||
},
|
},
|
||||||
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
||||||
};
|
};
|
||||||
|
use backend_service::errors::{invalid_params, ServerError};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use flowy_document_infra::protobuf::CreateDocParams;
|
use flowy_document_infra::protobuf::CreateDocParams;
|
||||||
use flowy_net::errors::{invalid_params, ServerError};
|
|
||||||
use flowy_workspace_infra::{
|
use flowy_workspace_infra::{
|
||||||
parser::{
|
parser::{
|
||||||
app::AppId,
|
app::AppId,
|
||||||
|
@ -14,7 +14,7 @@ use actix_web::{
|
|||||||
HttpResponse,
|
HttpResponse,
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use flowy_net::{
|
use backend_service::{
|
||||||
errors::{invalid_params, ServerError},
|
errors::{invalid_params, ServerError},
|
||||||
response::FlowyResponse,
|
response::FlowyResponse,
|
||||||
};
|
};
|
||||||
|
@ -2,8 +2,8 @@ use crate::{
|
|||||||
entities::workspace::{WorkspaceTable, WORKSPACE_TABLE},
|
entities::workspace::{WorkspaceTable, WORKSPACE_TABLE},
|
||||||
sqlx_ext::SqlBuilder,
|
sqlx_ext::SqlBuilder,
|
||||||
};
|
};
|
||||||
|
use backend_service::errors::{invalid_params, ServerError};
|
||||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||||
use flowy_net::errors::{invalid_params, ServerError};
|
|
||||||
use flowy_workspace_infra::{parser::workspace::WorkspaceId, protobuf::Workspace};
|
use flowy_workspace_infra::{parser::workspace::WorkspaceId, protobuf::Workspace};
|
||||||
use sqlx::postgres::PgArguments;
|
use sqlx::postgres::PgArguments;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -5,7 +5,7 @@ use crate::{
|
|||||||
sqlx_ext::*,
|
sqlx_ext::*,
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use flowy_net::errors::{invalid_params, ServerError};
|
use backend_service::errors::{invalid_params, ServerError};
|
||||||
use flowy_workspace_infra::{
|
use flowy_workspace_infra::{
|
||||||
parser::workspace::WorkspaceId,
|
parser::workspace::WorkspaceId,
|
||||||
protobuf::{RepeatedApp, RepeatedWorkspace, Workspace},
|
protobuf::{RepeatedApp, RepeatedWorkspace, Workspace},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::service::ws::WsMessageAdaptor;
|
use crate::service::ws::WsMessageAdaptor;
|
||||||
use actix::{Message, Recipient};
|
use actix::{Message, Recipient};
|
||||||
use flowy_net::errors::ServerError;
|
use backend_service::errors::ServerError;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::Formatter;
|
use std::fmt::Formatter;
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ use crate::service::ws::{
|
|||||||
WsMessageAdaptor,
|
WsMessageAdaptor,
|
||||||
};
|
};
|
||||||
use actix::{Actor, Context, Handler};
|
use actix::{Actor, Context, Handler};
|
||||||
|
use backend_service::errors::ServerError;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use flowy_net::errors::ServerError;
|
|
||||||
|
|
||||||
pub struct WsServer {
|
pub struct WsServer {
|
||||||
sessions: DashMap<SessionId, Session>,
|
sessions: DashMap<SessionId, Session>,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use flowy_net::errors::ServerError;
|
use backend_service::errors::ServerError;
|
||||||
use sql_builder::SqlBuilder as InnerBuilder;
|
use sql_builder::SqlBuilder as InnerBuilder;
|
||||||
use sqlx::{postgres::PgArguments, Arguments, Encode, Postgres, Type};
|
use sqlx::{postgres::PgArguments, Arguments, Encode, Postgres, Type};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use flowy_net::errors::{ErrorCode, ServerError};
|
use backend_service::errors::{ErrorCode, ServerError};
|
||||||
use sqlx::{Error, Postgres, Transaction};
|
use sqlx::{Error, Postgres, Transaction};
|
||||||
|
|
||||||
pub type DBTransaction<'a> = Transaction<'a, Postgres>;
|
pub type DBTransaction<'a> = Transaction<'a, Postgres>;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::util::helper::{spawn_user_server, TestUserServer};
|
use crate::util::helper::{spawn_user_server, TestUserServer};
|
||||||
use flowy_net::errors::ErrorCode;
|
use backend_service::errors::ErrorCode;
|
||||||
use flowy_user_infra::entities::{SignInParams, SignUpParams, SignUpResponse, UpdateUserParams};
|
use flowy_user_infra::entities::{SignInParams, SignUpParams, SignUpResponse, UpdateUserParams};
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use backend::service::doc::{crud::update_doc, doc::DocManager};
|
use backend::service::doc::{crud::update_doc, doc::DocManager};
|
||||||
|
use backend_service::config::ServerConfig;
|
||||||
use flowy_document::services::doc::ClientEditDoc as ClientEditDocContext;
|
use flowy_document::services::doc::ClientEditDoc as ClientEditDocContext;
|
||||||
use flowy_net::config::ServerConfig;
|
|
||||||
use flowy_test::{workspace::ViewTest, FlowyTest};
|
use flowy_test::{workspace::ViewTest, FlowyTest};
|
||||||
use flowy_user::services::user::UserSession;
|
use flowy_user::services::user::UserSession;
|
||||||
use futures_util::{stream, stream::StreamExt};
|
use futures_util::{stream, stream::StreamExt};
|
||||||
|
@ -3,10 +3,9 @@ use backend::{
|
|||||||
config::{get_configuration, DatabaseSettings},
|
config::{get_configuration, DatabaseSettings},
|
||||||
context::AppContext,
|
context::AppContext,
|
||||||
};
|
};
|
||||||
use backend_api::{user_request::*, workspace_request::*};
|
use backend_service::{errors::ServerError, user_request::*, workspace_request::*};
|
||||||
use flowy_document::services::server::read_doc_request;
|
use flowy_document::services::server::read_doc_request;
|
||||||
use flowy_document_infra::entities::doc::{Doc, DocIdentifier};
|
use flowy_document_infra::entities::doc::{Doc, DocIdentifier};
|
||||||
use flowy_net::errors::ServerError;
|
|
||||||
use flowy_user_infra::entities::*;
|
use flowy_user_infra::entities::*;
|
||||||
use flowy_workspace_infra::entities::prelude::*;
|
use flowy_workspace_infra::entities::prelude::*;
|
||||||
use sqlx::{Connection, Executor, PgConnection, PgPool};
|
use sqlx::{Connection, Executor, PgConnection, PgPool};
|
||||||
|
@ -3,7 +3,7 @@ members = [
|
|||||||
"lib-dispatch",
|
"lib-dispatch",
|
||||||
"flowy-sdk",
|
"flowy-sdk",
|
||||||
"dart-ffi",
|
"dart-ffi",
|
||||||
"lib-log",
|
"lib-log",
|
||||||
"flowy-user",
|
"flowy-user",
|
||||||
"flowy-user-infra",
|
"flowy-user-infra",
|
||||||
"flowy-ast",
|
"flowy-ast",
|
||||||
@ -18,9 +18,8 @@ members = [
|
|||||||
"flowy-document",
|
"flowy-document",
|
||||||
"flowy-document-infra",
|
"flowy-document-infra",
|
||||||
"lib-ot",
|
"lib-ot",
|
||||||
"flowy-net",
|
|
||||||
"lib-ws",
|
"lib-ws",
|
||||||
"backend-api",
|
"backend-service",
|
||||||
]
|
]
|
||||||
|
|
||||||
exclude = ["../backend"]
|
exclude = ["../backend"]
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "backend-api"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
flowy-net = { path = "../flowy-net", features = ["flowy_request"] }
|
|
||||||
flowy-workspace-infra = { path = "../flowy-workspace-infra" }
|
|
||||||
flowy-user-infra = { path = "../flowy-user-infra" }
|
|
||||||
log = "0.4.14"
|
|
||||||
lazy_static = "1.4.0"
|
|
||||||
tokio = { version = "1", features = ["rt"] }
|
|
@ -1,32 +1,30 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flowy-net"
|
name = "backend-service"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
flowy-workspace-infra = { path = "../flowy-workspace-infra" }
|
||||||
|
flowy-user-infra = { path = "../flowy-user-infra" }
|
||||||
|
|
||||||
|
log = "0.4.14"
|
||||||
|
lazy_static = "1.4.0"
|
||||||
|
tokio = { version = "1", features = ["rt"] }
|
||||||
|
anyhow = "1.0"
|
||||||
|
thiserror = "1.0.24"
|
||||||
|
bytes = { version = "1.0", features = ["serde"]}
|
||||||
reqwest = "0.11"
|
reqwest = "0.11"
|
||||||
hyper = "0.14"
|
hyper = "0.14"
|
||||||
protobuf = {version = "2.18.0"}
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde_repr = "0.1"
|
serde_repr = "0.1"
|
||||||
pin-project = "1.0.0"
|
|
||||||
futures-core = { version = "0.3", default-features = false }
|
|
||||||
log = "0.4"
|
|
||||||
tracing = { version = "0.1", features = ["log"] }
|
|
||||||
bytes = { version = "1.0", features = ["serde"]}
|
|
||||||
lazy_static = "1.4.0"
|
|
||||||
tokio = { version = "1", features = ["full"] }
|
|
||||||
actix-web = {version = "4.0.0-beta.8", optional = true}
|
|
||||||
derive_more = {version = "0.99", features = ["display"]}
|
|
||||||
flowy-derive = { path = "../flowy-derive" }
|
|
||||||
lib-infra = { path = "../lib-infra" }
|
|
||||||
anyhow = "1.0"
|
|
||||||
thiserror = "1.0.24"
|
|
||||||
uuid = { version = "0.8", features = ["v4"] }
|
uuid = { version = "0.8", features = ["v4"] }
|
||||||
|
protobuf = {version = "2.18.0"}
|
||||||
|
derive_more = {version = "0.99", features = ["display"]}
|
||||||
|
tracing = { version = "0.1", features = ["log"] }
|
||||||
|
actix-web = {version = "4.0.0-beta.8", optional = true}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
http_server = ["actix-web"]
|
http_server = ["actix-web"]
|
||||||
flowy_request = []
|
|
@ -1,3 +1,7 @@
|
|||||||
|
pub mod config;
|
||||||
|
pub mod errors;
|
||||||
pub mod middleware;
|
pub mod middleware;
|
||||||
|
pub mod request;
|
||||||
|
pub mod response;
|
||||||
pub mod user_request;
|
pub mod user_request;
|
||||||
pub mod workspace_request;
|
pub mod workspace_request;
|
@ -1,4 +1,4 @@
|
|||||||
use flowy_net::{request::ResponseMiddleware, response::FlowyResponse};
|
use crate::{request::ResponseMiddleware, response::FlowyResponse};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::broadcast;
|
use tokio::sync::broadcast;
|
@ -1,5 +1,4 @@
|
|||||||
mod response;
|
mod response;
|
||||||
mod response_serde;
|
|
||||||
|
|
||||||
#[cfg(feature = "http_server")]
|
#[cfg(feature = "http_server")]
|
||||||
mod response_http;
|
mod response_http;
|
@ -1,8 +1,8 @@
|
|||||||
use flowy_net::{config::HEADER_TOKEN, errors::ServerError, request::HttpRequestBuilder};
|
use crate::{config::HEADER_TOKEN, errors::ServerError, request::HttpRequestBuilder};
|
||||||
use flowy_user_infra::entities::prelude::*;
|
use flowy_user_infra::entities::prelude::*;
|
||||||
|
|
||||||
pub(crate) fn request_builder() -> HttpRequestBuilder {
|
pub(crate) fn request_builder() -> HttpRequestBuilder {
|
||||||
HttpRequestBuilder::new().middleware(super::middleware::BACKEND_API_MIDDLEWARE.clone())
|
HttpRequestBuilder::new().middleware(crate::middleware::BACKEND_API_MIDDLEWARE.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn user_sign_up_request(params: SignUpParams, url: &str) -> Result<SignUpResponse, ServerError> {
|
pub async fn user_sign_up_request(params: SignUpParams, url: &str) -> Result<SignUpResponse, ServerError> {
|
@ -1,8 +1,8 @@
|
|||||||
use flowy_net::{config::HEADER_TOKEN, errors::ServerError, request::HttpRequestBuilder};
|
use crate::{config::HEADER_TOKEN, errors::ServerError, request::HttpRequestBuilder};
|
||||||
use flowy_workspace_infra::entities::prelude::*;
|
use flowy_workspace_infra::entities::prelude::*;
|
||||||
|
|
||||||
pub(crate) fn request_builder() -> HttpRequestBuilder {
|
pub(crate) fn request_builder() -> HttpRequestBuilder {
|
||||||
HttpRequestBuilder::new().middleware(super::middleware::BACKEND_API_MIDDLEWARE.clone())
|
HttpRequestBuilder::new().middleware(crate::middleware::BACKEND_API_MIDDLEWARE.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_workspace_request(
|
pub async fn create_workspace_request(
|
@ -28,7 +28,7 @@ lib-dispatch = {path = "../lib-dispatch" }
|
|||||||
flowy-sdk = {path = "../flowy-sdk"}
|
flowy-sdk = {path = "../flowy-sdk"}
|
||||||
flowy-derive = {path = "../flowy-derive"}
|
flowy-derive = {path = "../flowy-derive"}
|
||||||
dart-notify = {path = "../dart-notify" }
|
dart-notify = {path = "../dart-notify" }
|
||||||
flowy-net = {path = "../flowy-net"}
|
backend-service = { path = "../backend-service" }
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -69,7 +69,7 @@ pub extern "C" fn set_stream_port(port: i64) -> i32 {
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn link_me_please() {}
|
pub extern "C" fn link_me_please() {}
|
||||||
|
|
||||||
use flowy_net::config::ServerConfig;
|
use backend_service::config::ServerConfig;
|
||||||
use lib_dispatch::prelude::ToBytes;
|
use lib_dispatch::prelude::ToBytes;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -16,7 +16,7 @@ lib-infra = { path = "../lib-infra" }
|
|||||||
dart-notify = { path = "../dart-notify" }
|
dart-notify = { path = "../dart-notify" }
|
||||||
lib-ot = { path = "../lib-ot" }
|
lib-ot = { path = "../lib-ot" }
|
||||||
lib-ws = { path = "../lib-ws" }
|
lib-ws = { path = "../lib-ws" }
|
||||||
flowy-net = { path = "../flowy-net", features = ["flowy_request"] }
|
backend-service = { path = "../backend-service" }
|
||||||
|
|
||||||
|
|
||||||
diesel = {version = "1.4.8", features = ["sqlite"]}
|
diesel = {version = "1.4.8", features = ["sqlite"]}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
use backend_service::errors::ServerError;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use derive_more::Display;
|
use derive_more::Display;
|
||||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||||
use flowy_net::errors::ServerError;
|
|
||||||
use lib_dispatch::prelude::{EventResponse, ResponseBuilder};
|
use lib_dispatch::prelude::{EventResponse, ResponseBuilder};
|
||||||
use std::{convert::TryInto, fmt};
|
use std::{convert::TryInto, fmt};
|
||||||
|
|
||||||
@ -108,14 +108,14 @@ impl std::convert::From<protobuf::ProtobufError> for DocError {
|
|||||||
fn from(e: protobuf::ProtobufError) -> Self { DocError::internal().context(e) }
|
fn from(e: protobuf::ProtobufError) -> Self { DocError::internal().context(e) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::From<flowy_net::errors::ServerError> for DocError {
|
impl std::convert::From<backend_service::errors::ServerError> for DocError {
|
||||||
fn from(error: ServerError) -> Self {
|
fn from(error: ServerError) -> Self {
|
||||||
let code = server_error_to_doc_error(error.code);
|
let code = server_error_to_doc_error(error.code);
|
||||||
DocError::new(code, &error.msg)
|
DocError::new(code, &error.msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use flowy_net::errors::ErrorCode as ServerErrorCode;
|
use backend_service::errors::ErrorCode as ServerErrorCode;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
fn server_error_to_doc_error(code: ServerErrorCode) -> ErrorCode {
|
fn server_error_to_doc_error(code: ServerErrorCode) -> ErrorCode {
|
||||||
|
@ -6,9 +6,9 @@ use crate::{
|
|||||||
ws::WsDocumentManager,
|
ws::WsDocumentManager,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use backend_service::config::ServerConfig;
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_document_infra::entities::doc::{DocDelta, DocIdentifier};
|
use flowy_document_infra::entities::doc::{DocDelta, DocIdentifier};
|
||||||
use flowy_net::config::ServerConfig;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub trait DocumentUser: Send + Sync {
|
pub trait DocumentUser: Send + Sync {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use flowy_net::{request::ResponseMiddleware, response::FlowyResponse};
|
use backend_service::{request::ResponseMiddleware, response::FlowyResponse};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ mod server_api_mock;
|
|||||||
pub use server_api::*;
|
pub use server_api::*;
|
||||||
// TODO: ignore mock files in production
|
// TODO: ignore mock files in production
|
||||||
use crate::errors::DocError;
|
use crate::errors::DocError;
|
||||||
|
use backend_service::config::ServerConfig;
|
||||||
use flowy_document_infra::entities::doc::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams};
|
use flowy_document_infra::entities::doc::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams};
|
||||||
use flowy_net::config::ServerConfig;
|
|
||||||
use lib_infra::future::ResultFuture;
|
use lib_infra::future::ResultFuture;
|
||||||
pub use server_api_mock::*;
|
pub use server_api_mock::*;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{errors::DocError, services::server::DocumentServerAPI};
|
use crate::{errors::DocError, services::server::DocumentServerAPI};
|
||||||
|
use backend_service::{config::*, request::HttpRequestBuilder};
|
||||||
use flowy_document_infra::entities::doc::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams};
|
use flowy_document_infra::entities::doc::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams};
|
||||||
use flowy_net::{config::*, request::HttpRequestBuilder};
|
|
||||||
use lib_infra::future::ResultFuture;
|
use lib_infra::future::ResultFuture;
|
||||||
|
|
||||||
pub struct DocServer {
|
pub struct DocServer {
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
pub mod config;
|
|
||||||
pub mod errors;
|
|
||||||
#[cfg(feature = "flowy_request")]
|
|
||||||
pub mod request;
|
|
||||||
pub mod response;
|
|
@ -1,123 +0,0 @@
|
|||||||
// use crate::response::{FlowyResponse, ServerCode};
|
|
||||||
// use serde::{
|
|
||||||
// de::{self, MapAccess, Visitor},
|
|
||||||
// Deserialize,
|
|
||||||
// Deserializer,
|
|
||||||
// Serialize,
|
|
||||||
// };
|
|
||||||
// use std::{fmt, marker::PhantomData, str::FromStr};
|
|
||||||
//
|
|
||||||
// pub trait ServerData<'a>: Serialize + Deserialize<'a> + FromStr<Err = ()> {}
|
|
||||||
// impl<'de, T: ServerData<'de>> Deserialize<'de> for FlowyResponse<T> {
|
|
||||||
// fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
// where
|
|
||||||
// D: Deserializer<'de>,
|
|
||||||
// {
|
|
||||||
// struct ServerResponseVisitor<T>(PhantomData<fn() -> T>);
|
|
||||||
// impl<'de, T> Visitor<'de> for ServerResponseVisitor<T>
|
|
||||||
// where
|
|
||||||
// T: ServerData<'de>,
|
|
||||||
// {
|
|
||||||
// type Value = FlowyResponse<T>;
|
|
||||||
//
|
|
||||||
// fn expecting(&self, formatter: &mut fmt::Formatter) ->
|
|
||||||
// fmt::Result { formatter.write_str("struct Duration") }
|
|
||||||
//
|
|
||||||
// fn visit_map<V>(self, mut map: V) -> Result<Self::Value,
|
|
||||||
// V::Error> where
|
|
||||||
// V: MapAccess<'de>,
|
|
||||||
// {
|
|
||||||
// let mut msg = None;
|
|
||||||
// let mut data: Option<T> = None;
|
|
||||||
// let mut code: Option<ServerCode> = None;
|
|
||||||
// while let Some(key) = map.next_key()? {
|
|
||||||
// match key {
|
|
||||||
// "msg" => {
|
|
||||||
// if msg.is_some() {
|
|
||||||
// return
|
|
||||||
// Err(de::Error::duplicate_field("msg")); }
|
|
||||||
// msg = Some(map.next_value()?);
|
|
||||||
// },
|
|
||||||
// "code" => {
|
|
||||||
// if code.is_some() {
|
|
||||||
// return
|
|
||||||
// Err(de::Error::duplicate_field("code")); }
|
|
||||||
// code = Some(map.next_value()?);
|
|
||||||
// },
|
|
||||||
// "data" => {
|
|
||||||
// if data.is_some() {
|
|
||||||
// return
|
|
||||||
// Err(de::Error::duplicate_field("data")); }
|
|
||||||
// data = match
|
|
||||||
// MapAccess::next_value::<DeserializeWith<T>>(&mut map) {
|
|
||||||
// Ok(wrapper) => wrapper.value, Err(err) =>
|
|
||||||
// return Err(err), };
|
|
||||||
// },
|
|
||||||
// _ => panic!(),
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// let msg = msg.ok_or_else(||
|
|
||||||
// de::Error::missing_field("msg"))?; let code =
|
|
||||||
// code.ok_or_else(|| de::Error::missing_field("code"))?;
|
|
||||||
// Ok(Self::Value::new(data, msg, code)) }
|
|
||||||
// }
|
|
||||||
// const FIELDS: &'static [&'static str] = &["msg", "code", "data"];
|
|
||||||
// deserializer.deserialize_struct("ServerResponse", FIELDS,
|
|
||||||
// ServerResponseVisitor(PhantomData)) }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// struct DeserializeWith<'de, T: ServerData<'de>> {
|
|
||||||
// value: Option<T>,
|
|
||||||
// phantom: PhantomData<&'de ()>,
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// impl<'de, T: ServerData<'de>> Deserialize<'de> for DeserializeWith<'de, T> {
|
|
||||||
// fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
// where
|
|
||||||
// D: Deserializer<'de>,
|
|
||||||
// {
|
|
||||||
// Ok(DeserializeWith {
|
|
||||||
// value: match string_or_data(deserializer) {
|
|
||||||
// Ok(val) => val,
|
|
||||||
// Err(e) => return Err(e),
|
|
||||||
// },
|
|
||||||
// phantom: PhantomData,
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fn string_or_data<'de, D, T>(deserializer: D) -> Result<Option<T>, D::Error>
|
|
||||||
// where
|
|
||||||
// D: Deserializer<'de>,
|
|
||||||
// T: ServerData<'de>,
|
|
||||||
// {
|
|
||||||
// struct StringOrData<T>(PhantomData<fn() -> T>);
|
|
||||||
// impl<'de, T: ServerData<'de>> Visitor<'de> for StringOrData<T> {
|
|
||||||
// type Value = Option<T>;
|
|
||||||
//
|
|
||||||
// fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
// formatter.write_str("string or struct impl deserialize") }
|
|
||||||
//
|
|
||||||
// fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
|
|
||||||
// where
|
|
||||||
// E: de::Error,
|
|
||||||
// {
|
|
||||||
// match FromStr::from_str(value) {
|
|
||||||
// Ok(val) => Ok(Some(val)),
|
|
||||||
// Err(_e) => Ok(None),
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fn visit_map<M>(self, map: M) -> Result<Self::Value, M::Error>
|
|
||||||
// where
|
|
||||||
// M: MapAccess<'de>,
|
|
||||||
// {
|
|
||||||
// match
|
|
||||||
// Deserialize::deserialize(de::value::MapAccessDeserializer::new(map)) {
|
|
||||||
// Ok(val) => Ok(Some(val)),
|
|
||||||
// Err(e) => Err(e),
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// deserializer.deserialize_any(StringOrData(PhantomData))
|
|
||||||
// }
|
|
@ -15,7 +15,7 @@ flowy-database = { path = "../flowy-database" }
|
|||||||
flowy-document = { path = "../flowy-document" }
|
flowy-document = { path = "../flowy-document" }
|
||||||
flowy-document-infra = { path = "../flowy-document-infra" }
|
flowy-document-infra = { path = "../flowy-document-infra" }
|
||||||
lib-ws = { path = "../lib-ws" }
|
lib-ws = { path = "../lib-ws" }
|
||||||
flowy-net = { path = "../flowy-net" }
|
backend-service = { path = "../backend-service" }
|
||||||
tracing = { version = "0.1" }
|
tracing = { version = "0.1" }
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
futures-core = { version = "0.3", default-features = false }
|
futures-core = { version = "0.3", default-features = false }
|
||||||
|
@ -3,8 +3,8 @@ mod deps_resolve;
|
|||||||
pub mod module;
|
pub mod module;
|
||||||
|
|
||||||
use crate::deps_resolve::WorkspaceDepsResolver;
|
use crate::deps_resolve::WorkspaceDepsResolver;
|
||||||
|
use backend_service::config::ServerConfig;
|
||||||
use flowy_document::module::FlowyDocument;
|
use flowy_document::module::FlowyDocument;
|
||||||
use flowy_net::config::ServerConfig;
|
|
||||||
use flowy_user::services::user::{UserSession, UserSessionBuilder, UserStatus};
|
use flowy_user::services::user::{UserSession, UserSessionBuilder, UserStatus};
|
||||||
use flowy_workspace::{errors::WorkspaceError, prelude::WorkspaceController};
|
use flowy_workspace::{errors::WorkspaceError, prelude::WorkspaceController};
|
||||||
use lib_dispatch::prelude::*;
|
use lib_dispatch::prelude::*;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::deps_resolve::DocumentDepsResolver;
|
use crate::deps_resolve::DocumentDepsResolver;
|
||||||
|
use backend_service::config::ServerConfig;
|
||||||
use flowy_document::module::FlowyDocument;
|
use flowy_document::module::FlowyDocument;
|
||||||
use flowy_net::config::ServerConfig;
|
|
||||||
use flowy_user::services::user::UserSession;
|
use flowy_user::services::user::UserSession;
|
||||||
use flowy_workspace::prelude::WorkspaceController;
|
use flowy_workspace::prelude::WorkspaceController;
|
||||||
use lib_dispatch::prelude::Module;
|
use lib_dispatch::prelude::Module;
|
||||||
|
@ -13,7 +13,7 @@ flowy-workspace = { path = "../flowy-workspace", default-features = false}
|
|||||||
lib-infra = { path = "../lib-infra" }
|
lib-infra = { path = "../lib-infra" }
|
||||||
flowy-document = { path = "../flowy-document"}
|
flowy-document = { path = "../flowy-document"}
|
||||||
flowy-document-infra = { path = "../flowy-document-infra"}
|
flowy-document-infra = { path = "../flowy-document-infra"}
|
||||||
flowy-net = { path = "../flowy-net"}
|
backend-service = { path = "../backend-service" }
|
||||||
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
bincode = { version = "1.3"}
|
bincode = { version = "1.3"}
|
||||||
|
@ -3,7 +3,7 @@ mod helper;
|
|||||||
pub mod workspace;
|
pub mod workspace;
|
||||||
|
|
||||||
use crate::helper::*;
|
use crate::helper::*;
|
||||||
use flowy_net::config::ServerConfig;
|
use backend_service::config::ServerConfig;
|
||||||
use flowy_sdk::{FlowySDK, FlowySDKConfig};
|
use flowy_sdk::{FlowySDK, FlowySDKConfig};
|
||||||
use flowy_user::entities::UserProfile;
|
use flowy_user::entities::UserProfile;
|
||||||
use lib_infra::uuid;
|
use lib_infra::uuid;
|
||||||
|
@ -7,14 +7,13 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
flowy-user-infra = { path = "../flowy-user-infra" }
|
flowy-user-infra = { path = "../flowy-user-infra" }
|
||||||
backend-api = { path = "../backend-api" }
|
backend-service = { path = "../backend-service" }
|
||||||
derive_more = {version = "0.99", features = ["display"]}
|
derive_more = {version = "0.99", features = ["display"]}
|
||||||
lib-dispatch = { path = "../lib-dispatch" }
|
lib-dispatch = { path = "../lib-dispatch" }
|
||||||
flowy-derive = { path = "../flowy-derive" }
|
flowy-derive = { path = "../flowy-derive" }
|
||||||
flowy-database = { path = "../flowy-database" }
|
flowy-database = { path = "../flowy-database" }
|
||||||
lib-sqlite = { path = "../lib-sqlite" }
|
lib-sqlite = { path = "../lib-sqlite" }
|
||||||
lib-infra = { path = "../lib-infra" }
|
lib-infra = { path = "../lib-infra" }
|
||||||
flowy-net = { path = "../flowy-net", features = ["flowy_request"] }
|
|
||||||
lib-ws = { path = "../lib-ws" }
|
lib-ws = { path = "../lib-ws" }
|
||||||
dart-notify = { path = "../dart-notify" }
|
dart-notify = { path = "../dart-notify" }
|
||||||
|
|
||||||
|
@ -92,15 +92,15 @@ impl std::convert::From<lib_sqlite::Error> for UserError {
|
|||||||
fn from(error: lib_sqlite::Error) -> Self { UserError::internal().context(error) }
|
fn from(error: lib_sqlite::Error) -> Self { UserError::internal().context(error) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::From<flowy_net::errors::ServerError> for UserError {
|
impl std::convert::From<backend_service::errors::ServerError> for UserError {
|
||||||
fn from(error: flowy_net::errors::ServerError) -> Self {
|
fn from(error: backend_service::errors::ServerError) -> Self {
|
||||||
let (code, msg) = server_error_to_user_error(error);
|
let (code, msg) = server_error_to_user_error(error);
|
||||||
UserError::new(code, &msg)
|
UserError::new(code, &msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use flowy_net::errors::ErrorCode as ServerErrorCode;
|
use backend_service::errors::ErrorCode as ServerErrorCode;
|
||||||
fn server_error_to_user_error(error: flowy_net::errors::ServerError) -> (ErrorCode, String) {
|
fn server_error_to_user_error(error: backend_service::errors::ServerError) -> (ErrorCode, String) {
|
||||||
let code = match error.code {
|
let code = match error.code {
|
||||||
ServerErrorCode::UserUnauthorized => ErrorCode::UserUnauthorized,
|
ServerErrorCode::UserUnauthorized => ErrorCode::UserUnauthorized,
|
||||||
ServerErrorCode::PasswordNotMatch => ErrorCode::PasswordNotMatch,
|
ServerErrorCode::PasswordNotMatch => ErrorCode::PasswordNotMatch,
|
||||||
|
@ -9,7 +9,7 @@ use crate::{
|
|||||||
entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserProfile},
|
entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserProfile},
|
||||||
errors::UserError,
|
errors::UserError,
|
||||||
};
|
};
|
||||||
use flowy_net::config::ServerConfig;
|
use backend_service::config::ServerConfig;
|
||||||
use lib_infra::future::ResultFuture;
|
use lib_infra::future::ResultFuture;
|
||||||
|
|
||||||
pub trait UserServerAPI {
|
pub trait UserServerAPI {
|
||||||
|
@ -3,8 +3,7 @@ use crate::{
|
|||||||
errors::UserError,
|
errors::UserError,
|
||||||
services::server::UserServerAPI,
|
services::server::UserServerAPI,
|
||||||
};
|
};
|
||||||
use backend_api::user_request::*;
|
use backend_service::{config::*, user_request::*};
|
||||||
use flowy_net::config::*;
|
|
||||||
use lib_infra::future::ResultFuture;
|
use lib_infra::future::ResultFuture;
|
||||||
|
|
||||||
pub struct UserServer {
|
pub struct UserServer {
|
||||||
@ -62,7 +61,7 @@ impl UserServerAPI for UserServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// use crate::notify::*;
|
// use crate::notify::*;
|
||||||
// use flowy_net::response::FlowyResponse;
|
// use backend_service::response::FlowyResponse;
|
||||||
// use flowy_user_infra::errors::ErrorCode;
|
// use flowy_user_infra::errors::ErrorCode;
|
||||||
|
|
||||||
// struct Middleware {}
|
// struct Middleware {}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::services::user::{UserSession, UserSessionConfig};
|
use crate::services::user::{UserSession, UserSessionConfig};
|
||||||
use flowy_net::config::ServerConfig;
|
use backend_service::config::ServerConfig;
|
||||||
|
|
||||||
pub struct UserSessionBuilder {
|
pub struct UserSessionBuilder {
|
||||||
config: Option<UserSessionConfig>,
|
config: Option<UserSessionConfig>,
|
||||||
|
@ -9,6 +9,7 @@ use crate::{
|
|||||||
notify::*,
|
notify::*,
|
||||||
services::server::{construct_user_server, Server},
|
services::server::{construct_user_server, Server},
|
||||||
};
|
};
|
||||||
|
use backend_service::config::ServerConfig;
|
||||||
use flowy_database::{
|
use flowy_database::{
|
||||||
query_dsl::*,
|
query_dsl::*,
|
||||||
schema::{user_table, user_table::dsl},
|
schema::{user_table, user_table::dsl},
|
||||||
@ -16,7 +17,6 @@ use flowy_database::{
|
|||||||
ExpressionMethods,
|
ExpressionMethods,
|
||||||
UserDatabaseConnection,
|
UserDatabaseConnection,
|
||||||
};
|
};
|
||||||
use flowy_net::config::ServerConfig;
|
|
||||||
use lib_infra::kv::KV;
|
use lib_infra::kv::KV;
|
||||||
use lib_sqlite::ConnectionPool;
|
use lib_sqlite::ConnectionPool;
|
||||||
use lib_ws::{WsController, WsMessageHandler, WsState};
|
use lib_ws::{WsController, WsMessageHandler, WsState};
|
||||||
|
@ -16,8 +16,7 @@ lib-sqlite = { path = "../lib-sqlite" }
|
|||||||
lib-infra = { path = "../lib-infra" }
|
lib-infra = { path = "../lib-infra" }
|
||||||
dart-notify = { path = "../dart-notify" }
|
dart-notify = { path = "../dart-notify" }
|
||||||
lib-ot = { path = "../lib-ot" }
|
lib-ot = { path = "../lib-ot" }
|
||||||
flowy-net = { path = "../flowy-net", features = ["flowy_request"] }
|
backend-service = { path = "../backend-service" }
|
||||||
backend-api = { path = "../backend-api" }
|
|
||||||
|
|
||||||
parking_lot = "0.11"
|
parking_lot = "0.11"
|
||||||
protobuf = {version = "2.18.0"}
|
protobuf = {version = "2.18.0"}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
|
||||||
|
use backend_service::errors::ErrorCode as ServerErrorCode;
|
||||||
use flowy_derive::ProtoBuf;
|
use flowy_derive::ProtoBuf;
|
||||||
use flowy_document::errors::DocError;
|
use flowy_document::errors::DocError;
|
||||||
use flowy_net::errors::ErrorCode as ServerErrorCode;
|
|
||||||
pub use flowy_workspace_infra::errors::ErrorCode;
|
pub use flowy_workspace_infra::errors::ErrorCode;
|
||||||
use lib_dispatch::prelude::{EventResponse, ResponseBuilder};
|
use lib_dispatch::prelude::{EventResponse, ResponseBuilder};
|
||||||
use std::{convert::TryInto, fmt, fmt::Debug};
|
use std::{convert::TryInto, fmt, fmt::Debug};
|
||||||
@ -75,8 +75,8 @@ impl std::convert::From<flowy_document::errors::DocError> for WorkspaceError {
|
|||||||
fn from(error: DocError) -> Self { WorkspaceError::internal().context(error) }
|
fn from(error: DocError) -> Self { WorkspaceError::internal().context(error) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::From<flowy_net::errors::ServerError> for WorkspaceError {
|
impl std::convert::From<backend_service::errors::ServerError> for WorkspaceError {
|
||||||
fn from(error: flowy_net::errors::ServerError) -> Self {
|
fn from(error: backend_service::errors::ServerError) -> Self {
|
||||||
let code = server_error_to_workspace_error(error.code);
|
let code = server_error_to_workspace_error(error.code);
|
||||||
WorkspaceError::new(code, &error.msg)
|
WorkspaceError::new(code, &error.msg)
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ use crate::{
|
|||||||
handlers::*,
|
handlers::*,
|
||||||
services::{server::construct_workspace_server, AppController, TrashCan, ViewController, WorkspaceController},
|
services::{server::construct_workspace_server, AppController, TrashCan, ViewController, WorkspaceController},
|
||||||
};
|
};
|
||||||
|
use backend_service::config::ServerConfig;
|
||||||
use flowy_database::DBConnection;
|
use flowy_database::DBConnection;
|
||||||
use flowy_document::module::FlowyDocument;
|
use flowy_document::module::FlowyDocument;
|
||||||
use flowy_net::config::ServerConfig;
|
|
||||||
use lib_dispatch::prelude::*;
|
use lib_dispatch::prelude::*;
|
||||||
use lib_sqlite::ConnectionPool;
|
use lib_sqlite::ConnectionPool;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -14,7 +14,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
errors::WorkspaceError,
|
errors::WorkspaceError,
|
||||||
};
|
};
|
||||||
use flowy_net::config::ServerConfig;
|
use backend_service::config::ServerConfig;
|
||||||
use lib_infra::future::ResultFuture;
|
use lib_infra::future::ResultFuture;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
@ -9,8 +9,7 @@ use crate::{
|
|||||||
notify::{send_dart_notification, WorkspaceNotification},
|
notify::{send_dart_notification, WorkspaceNotification},
|
||||||
services::server::WorkspaceServerAPI,
|
services::server::WorkspaceServerAPI,
|
||||||
};
|
};
|
||||||
use backend_api::{middleware::*, workspace_request::*};
|
use backend_service::{config::ServerConfig, middleware::*, workspace_request::*};
|
||||||
use flowy_net::config::ServerConfig;
|
|
||||||
use flowy_workspace_infra::errors::ErrorCode;
|
use flowy_workspace_infra::errors::ErrorCode;
|
||||||
use lib_infra::future::ResultFuture;
|
use lib_infra::future::ResultFuture;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
flowy-derive = { path = "../flowy-derive" }
|
flowy-derive = { path = "../flowy-derive" }
|
||||||
flowy-net = { path = "../flowy-net" }
|
backend-service = { path = "../backend-service" }
|
||||||
lib-infra = { path = "../lib-infra" }
|
lib-infra = { path = "../lib-infra" }
|
||||||
|
|
||||||
tokio-tungstenite = "0.15"
|
tokio-tungstenite = "0.15"
|
||||||
|
@ -4,9 +4,9 @@ use crate::{
|
|||||||
WsMessage,
|
WsMessage,
|
||||||
WsModule,
|
WsModule,
|
||||||
};
|
};
|
||||||
|
use backend_service::errors::ServerError;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use flowy_net::errors::ServerError;
|
|
||||||
use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};
|
use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};
|
||||||
use futures_core::{ready, Stream};
|
use futures_core::{ready, Stream};
|
||||||
use lib_infra::retry::{Action, FixedInterval, Retry};
|
use lib_infra::retry::{Action, FixedInterval, Retry};
|
||||||
|
Reference in New Issue
Block a user