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:
parent
a06a2b9e5b
commit
f93f012bc8
@ -65,7 +65,7 @@ flowy-workspace-infra = { path = "../rust-lib/flowy-workspace-infra" }
|
||||
flowy-document-infra = { path = "../rust-lib/flowy-document-infra" }
|
||||
lib-ws = { path = "../rust-lib/lib-ws" }
|
||||
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"]}
|
||||
[dependencies.sqlx]
|
||||
@ -99,7 +99,6 @@ parking_lot = "0.11"
|
||||
once_cell = "1.7.2"
|
||||
linkify = "0.5.0"
|
||||
backend = { path = ".", features = ["flowy_test"]}
|
||||
backend-api = { path = "../rust-lib/backend-api" }
|
||||
flowy-sdk = { path = "../rust-lib/flowy-sdk", 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"] }
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::config::env::{domain, jwt_secret};
|
||||
use backend_service::errors::ServerError;
|
||||
use chrono::{Duration, Local};
|
||||
use derive_more::{From, Into};
|
||||
use flowy_net::errors::ServerError;
|
||||
use jsonwebtoken::{decode, encode, Algorithm, DecodingKey, EncodingKey, Header, Validation};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -76,7 +76,7 @@ impl Token {
|
||||
|
||||
use crate::service::user::EXPIRED_DURATION_DAYS;
|
||||
use actix_web::{dev::Payload, FromRequest, HttpRequest};
|
||||
use flowy_net::config::HEADER_TOKEN;
|
||||
use backend_service::config::HEADER_TOKEN;
|
||||
use futures::future::{ready, Ready};
|
||||
|
||||
impl FromRequest for Token {
|
||||
|
@ -9,7 +9,7 @@ use actix_web::{
|
||||
|
||||
use crate::config::IGNORE_ROUTES;
|
||||
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 std::{
|
||||
convert::TryInto,
|
||||
|
@ -5,8 +5,8 @@ use crate::{
|
||||
};
|
||||
|
||||
use crate::service::trash::read_trash_ids;
|
||||
use backend_service::errors::{invalid_params, ServerError};
|
||||
use chrono::Utc;
|
||||
use flowy_net::errors::{invalid_params, ServerError};
|
||||
use flowy_workspace_infra::{
|
||||
parser::{
|
||||
app::{AppDesc, AppName},
|
||||
|
@ -2,7 +2,7 @@ use actix_web::{
|
||||
web::{Data, Payload},
|
||||
HttpResponse,
|
||||
};
|
||||
use flowy_net::errors::{invalid_params, ServerError};
|
||||
use backend_service::errors::{invalid_params, ServerError};
|
||||
use flowy_workspace_infra::protobuf::{AppIdentifier, CreateAppParams, UpdateAppParams};
|
||||
use protobuf::Message;
|
||||
use sqlx::PgPool;
|
||||
@ -16,7 +16,7 @@ use crate::service::{
|
||||
util::parse_from_payload,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use flowy_net::response::FlowyResponse;
|
||||
use backend_service::response::FlowyResponse;
|
||||
use flowy_workspace_infra::parser::app::{AppDesc, AppName};
|
||||
|
||||
pub async fn create_handler(
|
||||
|
@ -2,8 +2,8 @@ use crate::{
|
||||
entities::workspace::{AppTable, APP_TABLE},
|
||||
sqlx_ext::SqlBuilder,
|
||||
};
|
||||
use backend_service::errors::{invalid_params, ServerError};
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use flowy_net::errors::{invalid_params, ServerError};
|
||||
use flowy_workspace_infra::{
|
||||
parser::app::AppId,
|
||||
protobuf::{App, ColorStyle},
|
||||
|
@ -3,8 +3,8 @@ use crate::{
|
||||
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
||||
};
|
||||
use anyhow::Context;
|
||||
use backend_service::errors::ServerError;
|
||||
use flowy_document_infra::protobuf::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams};
|
||||
use flowy_net::errors::ServerError;
|
||||
use sqlx::{postgres::PgArguments, PgPool, Postgres};
|
||||
use uuid::Uuid;
|
||||
|
||||
|
@ -7,9 +7,9 @@ use crate::service::{
|
||||
ws::{WsBizHandler, WsClientData},
|
||||
};
|
||||
use actix_web::web::Data;
|
||||
use backend_service::errors::{internal_error, ServerError};
|
||||
use dashmap::DashMap;
|
||||
use flowy_document_infra::protobuf::DocIdentifier;
|
||||
use flowy_net::errors::{internal_error, ServerError};
|
||||
use sqlx::PgPool;
|
||||
use std::sync::Arc;
|
||||
use tokio::{
|
||||
|
@ -4,8 +4,8 @@ use crate::service::{
|
||||
};
|
||||
use actix_web::web::Data;
|
||||
use async_stream::stream;
|
||||
use backend_service::errors::{internal_error, Result as DocResult, ServerError};
|
||||
use flowy_document_infra::protobuf::{Doc, Revision};
|
||||
use flowy_net::errors::{internal_error, Result as DocResult, ServerError};
|
||||
use futures::stream::StreamExt;
|
||||
use sqlx::PgPool;
|
||||
use std::sync::{atomic::Ordering::SeqCst, Arc};
|
||||
|
@ -4,13 +4,13 @@ use crate::service::{
|
||||
ws::{entities::Socket, WsMessageAdaptor},
|
||||
};
|
||||
use actix_web::web::Data;
|
||||
use backend_service::errors::{internal_error, ServerError};
|
||||
use dashmap::DashMap;
|
||||
use flowy_document_infra::{
|
||||
core::Document,
|
||||
entities::ws::{WsDataType, WsDocumentData},
|
||||
protobuf::{Doc, RevId, RevType, Revision, RevisionRange, UpdateDocParams},
|
||||
};
|
||||
use flowy_net::errors::{internal_error, ServerError};
|
||||
use lib_ot::core::{Delta, OperationTransformable};
|
||||
use parking_lot::RwLock;
|
||||
use protobuf::Message;
|
||||
|
@ -3,8 +3,8 @@ use crate::service::{
|
||||
ws::{entities::Socket, WsUser},
|
||||
};
|
||||
use actix_web::web::Data;
|
||||
use backend_service::errors::{internal_error, Result as DocResult, ServerError};
|
||||
use flowy_document_infra::protobuf::{Doc, Revision};
|
||||
use flowy_net::errors::{internal_error, Result as DocResult, ServerError};
|
||||
use sqlx::PgPool;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
|
@ -7,8 +7,8 @@ use actix_web::{
|
||||
HttpResponse,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use backend_service::{errors::ServerError, response::FlowyResponse};
|
||||
use flowy_document_infra::protobuf::{CreateDocParams, DocIdentifier, UpdateDocParams};
|
||||
use flowy_net::{errors::ServerError, response::FlowyResponse};
|
||||
use sqlx::PgPool;
|
||||
|
||||
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_web::web::Data;
|
||||
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_net::errors::{internal_error, Result as DocResult, ServerError};
|
||||
use futures::stream::StreamExt;
|
||||
use sqlx::PgPool;
|
||||
use std::sync::Arc;
|
||||
|
@ -9,7 +9,7 @@ use actix_web::{
|
||||
HttpResponse,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use flowy_net::{
|
||||
use backend_service::{
|
||||
errors::{invalid_params, ServerError},
|
||||
response::FlowyResponse,
|
||||
};
|
||||
|
@ -8,7 +8,7 @@ use crate::{
|
||||
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
||||
};
|
||||
use ::protobuf::ProtobufEnum;
|
||||
use flowy_net::errors::ServerError;
|
||||
use backend_service::errors::ServerError;
|
||||
use flowy_workspace_infra::protobuf::{RepeatedTrash, Trash, TrashType};
|
||||
use sqlx::{postgres::PgArguments, Postgres, Row};
|
||||
use uuid::Uuid;
|
||||
|
@ -4,11 +4,11 @@ use crate::{
|
||||
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
||||
};
|
||||
use anyhow::Context;
|
||||
use chrono::Utc;
|
||||
use flowy_net::{
|
||||
use backend_service::{
|
||||
errors::{invalid_params, ErrorCode, ServerError},
|
||||
response::FlowyResponse,
|
||||
};
|
||||
use chrono::Utc;
|
||||
use flowy_user_infra::{
|
||||
parser::{UserEmail, UserName, UserPassword},
|
||||
protobuf::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserProfile},
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::entities::token::{Claim, Token};
|
||||
use actix_web::http::HeaderValue;
|
||||
use backend_service::errors::ServerError;
|
||||
use chrono::{DateTime, Utc};
|
||||
use dashmap::DashMap;
|
||||
use flowy_net::errors::ServerError;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
lazy_static! {
|
||||
|
@ -6,7 +6,7 @@ use actix_web::{
|
||||
};
|
||||
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 crate::{
|
||||
|
@ -7,9 +7,9 @@ use crate::{
|
||||
};
|
||||
|
||||
use crate::service::view::{create_view_with_args, sql_builder::NewViewSqlBuilder};
|
||||
use backend_service::errors::ServerError;
|
||||
use chrono::Utc;
|
||||
use flowy_document_infra::user_default::doc_initial_string;
|
||||
use flowy_net::errors::ServerError;
|
||||
use flowy_workspace_infra::protobuf::Workspace;
|
||||
use std::convert::TryInto;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use backend_service::errors::{ErrorCode, ServerError};
|
||||
use bcrypt::{hash, verify, DEFAULT_COST};
|
||||
use flowy_net::errors::{ErrorCode, ServerError};
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn uuid() -> String { uuid::Uuid::new_v4().to_string() }
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::config::MAX_PAYLOAD_SIZE;
|
||||
use actix_web::web;
|
||||
use flowy_net::errors::{ErrorCode, ServerError};
|
||||
use backend_service::errors::{ErrorCode, ServerError};
|
||||
use futures::StreamExt;
|
||||
use protobuf::{Message, ProtobufResult};
|
||||
|
||||
@ -10,9 +10,7 @@ pub async fn parse_from_payload<T: Message>(payload: web::Payload) -> Result<T,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn parse_from_dev_payload<T: Message>(
|
||||
payload: &mut actix_web::dev::Payload,
|
||||
) -> Result<T, ServerError> {
|
||||
pub async fn parse_from_dev_payload<T: Message>(payload: &mut actix_web::dev::Payload) -> Result<T, ServerError> {
|
||||
let bytes = poll_payload(payload).await?;
|
||||
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(
|
||||
payload: &mut actix_web::dev::Payload,
|
||||
) -> Result<web::BytesMut, ServerError> {
|
||||
pub async fn poll_payload(payload: &mut actix_web::dev::Payload) -> Result<web::BytesMut, ServerError> {
|
||||
let mut body = web::BytesMut::new();
|
||||
while let Some(chunk) = payload.next().await {
|
||||
let chunk = chunk.map_err(|err| ServerError::internal().context(err))?;
|
||||
|
@ -9,7 +9,7 @@ use actix_web::{
|
||||
HttpResponse,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use flowy_net::{
|
||||
use backend_service::{
|
||||
errors::{invalid_params, ServerError},
|
||||
response::FlowyResponse,
|
||||
};
|
||||
|
@ -2,8 +2,8 @@ use crate::{
|
||||
entities::workspace::{ViewTable, VIEW_TABLE},
|
||||
sqlx_ext::SqlBuilder,
|
||||
};
|
||||
use backend_service::errors::{invalid_params, ServerError};
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use flowy_net::errors::{invalid_params, ServerError};
|
||||
use flowy_workspace_infra::{
|
||||
parser::view::ViewId,
|
||||
protobuf::{View, ViewType},
|
||||
|
@ -8,9 +8,9 @@ use crate::{
|
||||
},
|
||||
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
||||
};
|
||||
use backend_service::errors::{invalid_params, ServerError};
|
||||
use chrono::Utc;
|
||||
use flowy_document_infra::protobuf::CreateDocParams;
|
||||
use flowy_net::errors::{invalid_params, ServerError};
|
||||
use flowy_workspace_infra::{
|
||||
parser::{
|
||||
app::AppId,
|
||||
|
@ -14,7 +14,7 @@ use actix_web::{
|
||||
HttpResponse,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use flowy_net::{
|
||||
use backend_service::{
|
||||
errors::{invalid_params, ServerError},
|
||||
response::FlowyResponse,
|
||||
};
|
||||
|
@ -2,8 +2,8 @@ use crate::{
|
||||
entities::workspace::{WorkspaceTable, WORKSPACE_TABLE},
|
||||
sqlx_ext::SqlBuilder,
|
||||
};
|
||||
use backend_service::errors::{invalid_params, ServerError};
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use flowy_net::errors::{invalid_params, ServerError};
|
||||
use flowy_workspace_infra::{parser::workspace::WorkspaceId, protobuf::Workspace};
|
||||
use sqlx::postgres::PgArguments;
|
||||
use uuid::Uuid;
|
||||
|
@ -5,7 +5,7 @@ use crate::{
|
||||
sqlx_ext::*,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use flowy_net::errors::{invalid_params, ServerError};
|
||||
use backend_service::errors::{invalid_params, ServerError};
|
||||
use flowy_workspace_infra::{
|
||||
parser::workspace::WorkspaceId,
|
||||
protobuf::{RepeatedApp, RepeatedWorkspace, Workspace},
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::service::ws::WsMessageAdaptor;
|
||||
use actix::{Message, Recipient};
|
||||
use flowy_net::errors::ServerError;
|
||||
use backend_service::errors::ServerError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Formatter;
|
||||
|
||||
|
@ -3,8 +3,8 @@ use crate::service::ws::{
|
||||
WsMessageAdaptor,
|
||||
};
|
||||
use actix::{Actor, Context, Handler};
|
||||
use backend_service::errors::ServerError;
|
||||
use dashmap::DashMap;
|
||||
use flowy_net::errors::ServerError;
|
||||
|
||||
pub struct WsServer {
|
||||
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 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};
|
||||
|
||||
pub type DBTransaction<'a> = Transaction<'a, Postgres>;
|
||||
|
@ -1,5 +1,5 @@
|
||||
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};
|
||||
|
||||
#[actix_rt::test]
|
||||
|
@ -1,7 +1,7 @@
|
||||
use actix_web::web::Data;
|
||||
use backend::service::doc::{crud::update_doc, doc::DocManager};
|
||||
use backend_service::config::ServerConfig;
|
||||
use flowy_document::services::doc::ClientEditDoc as ClientEditDocContext;
|
||||
use flowy_net::config::ServerConfig;
|
||||
use flowy_test::{workspace::ViewTest, FlowyTest};
|
||||
use flowy_user::services::user::UserSession;
|
||||
use futures_util::{stream, stream::StreamExt};
|
||||
|
@ -3,10 +3,9 @@ use backend::{
|
||||
config::{get_configuration, DatabaseSettings},
|
||||
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_infra::entities::doc::{Doc, DocIdentifier};
|
||||
use flowy_net::errors::ServerError;
|
||||
use flowy_user_infra::entities::*;
|
||||
use flowy_workspace_infra::entities::prelude::*;
|
||||
use sqlx::{Connection, Executor, PgConnection, PgPool};
|
||||
|
@ -3,7 +3,7 @@ members = [
|
||||
"lib-dispatch",
|
||||
"flowy-sdk",
|
||||
"dart-ffi",
|
||||
"lib-log",
|
||||
"lib-log",
|
||||
"flowy-user",
|
||||
"flowy-user-infra",
|
||||
"flowy-ast",
|
||||
@ -18,9 +18,8 @@ members = [
|
||||
"flowy-document",
|
||||
"flowy-document-infra",
|
||||
"lib-ot",
|
||||
"flowy-net",
|
||||
"lib-ws",
|
||||
"backend-api",
|
||||
"backend-service",
|
||||
]
|
||||
|
||||
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]
|
||||
name = "flowy-net"
|
||||
name = "backend-service"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[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"
|
||||
hyper = "0.14"
|
||||
protobuf = {version = "2.18.0"}
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
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"] }
|
||||
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]
|
||||
http_server = ["actix-web"]
|
||||
flowy_request = []
|
||||
http_server = ["actix-web"]
|
@ -1,3 +1,7 @@
|
||||
pub mod config;
|
||||
pub mod errors;
|
||||
pub mod middleware;
|
||||
pub mod request;
|
||||
pub mod response;
|
||||
pub mod user_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 std::sync::Arc;
|
||||
use tokio::sync::broadcast;
|
@ -1,5 +1,4 @@
|
||||
mod response;
|
||||
mod response_serde;
|
||||
|
||||
#[cfg(feature = "http_server")]
|
||||
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::*;
|
||||
|
||||
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> {
|
@ -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::*;
|
||||
|
||||
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(
|
@ -28,7 +28,7 @@ lib-dispatch = {path = "../lib-dispatch" }
|
||||
flowy-sdk = {path = "../flowy-sdk"}
|
||||
flowy-derive = {path = "../flowy-derive"}
|
||||
dart-notify = {path = "../dart-notify" }
|
||||
flowy-net = {path = "../flowy-net"}
|
||||
backend-service = { path = "../backend-service" }
|
||||
|
||||
|
||||
[features]
|
||||
|
@ -69,7 +69,7 @@ pub extern "C" fn set_stream_port(port: i64) -> i32 {
|
||||
#[no_mangle]
|
||||
pub extern "C" fn link_me_please() {}
|
||||
|
||||
use flowy_net::config::ServerConfig;
|
||||
use backend_service::config::ServerConfig;
|
||||
use lib_dispatch::prelude::ToBytes;
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -16,7 +16,7 @@ lib-infra = { path = "../lib-infra" }
|
||||
dart-notify = { path = "../dart-notify" }
|
||||
lib-ot = { path = "../lib-ot" }
|
||||
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"]}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use backend_service::errors::ServerError;
|
||||
use bytes::Bytes;
|
||||
use derive_more::Display;
|
||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||
use flowy_net::errors::ServerError;
|
||||
use lib_dispatch::prelude::{EventResponse, ResponseBuilder};
|
||||
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) }
|
||||
}
|
||||
|
||||
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 {
|
||||
let code = server_error_to_doc_error(error.code);
|
||||
DocError::new(code, &error.msg)
|
||||
}
|
||||
}
|
||||
|
||||
use flowy_net::errors::ErrorCode as ServerErrorCode;
|
||||
use backend_service::errors::ErrorCode as ServerErrorCode;
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn server_error_to_doc_error(code: ServerErrorCode) -> ErrorCode {
|
||||
|
@ -6,9 +6,9 @@ use crate::{
|
||||
ws::WsDocumentManager,
|
||||
},
|
||||
};
|
||||
use backend_service::config::ServerConfig;
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_document_infra::entities::doc::{DocDelta, DocIdentifier};
|
||||
use flowy_net::config::ServerConfig;
|
||||
use std::sync::Arc;
|
||||
|
||||
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 std::sync::Arc;
|
||||
|
||||
|
@ -5,8 +5,8 @@ mod server_api_mock;
|
||||
pub use server_api::*;
|
||||
// TODO: ignore mock files in production
|
||||
use crate::errors::DocError;
|
||||
use backend_service::config::ServerConfig;
|
||||
use flowy_document_infra::entities::doc::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams};
|
||||
use flowy_net::config::ServerConfig;
|
||||
use lib_infra::future::ResultFuture;
|
||||
pub use server_api_mock::*;
|
||||
use std::sync::Arc;
|
||||
|
@ -1,6 +1,6 @@
|
||||
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_net::{config::*, request::HttpRequestBuilder};
|
||||
use lib_infra::future::ResultFuture;
|
||||
|
||||
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-infra = { path = "../flowy-document-infra" }
|
||||
lib-ws = { path = "../lib-ws" }
|
||||
flowy-net = { path = "../flowy-net" }
|
||||
backend-service = { path = "../backend-service" }
|
||||
tracing = { version = "0.1" }
|
||||
log = "0.4.14"
|
||||
futures-core = { version = "0.3", default-features = false }
|
||||
|
@ -3,8 +3,8 @@ mod deps_resolve;
|
||||
pub mod module;
|
||||
|
||||
use crate::deps_resolve::WorkspaceDepsResolver;
|
||||
use backend_service::config::ServerConfig;
|
||||
use flowy_document::module::FlowyDocument;
|
||||
use flowy_net::config::ServerConfig;
|
||||
use flowy_user::services::user::{UserSession, UserSessionBuilder, UserStatus};
|
||||
use flowy_workspace::{errors::WorkspaceError, prelude::WorkspaceController};
|
||||
use lib_dispatch::prelude::*;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::deps_resolve::DocumentDepsResolver;
|
||||
use backend_service::config::ServerConfig;
|
||||
use flowy_document::module::FlowyDocument;
|
||||
use flowy_net::config::ServerConfig;
|
||||
use flowy_user::services::user::UserSession;
|
||||
use flowy_workspace::prelude::WorkspaceController;
|
||||
use lib_dispatch::prelude::Module;
|
||||
|
@ -13,7 +13,7 @@ flowy-workspace = { path = "../flowy-workspace", default-features = false}
|
||||
lib-infra = { path = "../lib-infra" }
|
||||
flowy-document = { path = "../flowy-document"}
|
||||
flowy-document-infra = { path = "../flowy-document-infra"}
|
||||
flowy-net = { path = "../flowy-net"}
|
||||
backend-service = { path = "../backend-service" }
|
||||
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
bincode = { version = "1.3"}
|
||||
|
@ -3,7 +3,7 @@ mod helper;
|
||||
pub mod workspace;
|
||||
|
||||
use crate::helper::*;
|
||||
use flowy_net::config::ServerConfig;
|
||||
use backend_service::config::ServerConfig;
|
||||
use flowy_sdk::{FlowySDK, FlowySDKConfig};
|
||||
use flowy_user::entities::UserProfile;
|
||||
use lib_infra::uuid;
|
||||
|
@ -7,14 +7,13 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
flowy-user-infra = { path = "../flowy-user-infra" }
|
||||
backend-api = { path = "../backend-api" }
|
||||
backend-service = { path = "../backend-service" }
|
||||
derive_more = {version = "0.99", features = ["display"]}
|
||||
lib-dispatch = { path = "../lib-dispatch" }
|
||||
flowy-derive = { path = "../flowy-derive" }
|
||||
flowy-database = { path = "../flowy-database" }
|
||||
lib-sqlite = { path = "../lib-sqlite" }
|
||||
lib-infra = { path = "../lib-infra" }
|
||||
flowy-net = { path = "../flowy-net", features = ["flowy_request"] }
|
||||
lib-ws = { path = "../lib-ws" }
|
||||
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) }
|
||||
}
|
||||
|
||||
impl std::convert::From<flowy_net::errors::ServerError> for UserError {
|
||||
fn from(error: flowy_net::errors::ServerError) -> Self {
|
||||
impl std::convert::From<backend_service::errors::ServerError> for UserError {
|
||||
fn from(error: backend_service::errors::ServerError) -> Self {
|
||||
let (code, msg) = server_error_to_user_error(error);
|
||||
UserError::new(code, &msg)
|
||||
}
|
||||
}
|
||||
|
||||
use flowy_net::errors::ErrorCode as ServerErrorCode;
|
||||
fn server_error_to_user_error(error: flowy_net::errors::ServerError) -> (ErrorCode, String) {
|
||||
use backend_service::errors::ErrorCode as ServerErrorCode;
|
||||
fn server_error_to_user_error(error: backend_service::errors::ServerError) -> (ErrorCode, String) {
|
||||
let code = match error.code {
|
||||
ServerErrorCode::UserUnauthorized => ErrorCode::UserUnauthorized,
|
||||
ServerErrorCode::PasswordNotMatch => ErrorCode::PasswordNotMatch,
|
||||
|
@ -9,7 +9,7 @@ use crate::{
|
||||
entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserProfile},
|
||||
errors::UserError,
|
||||
};
|
||||
use flowy_net::config::ServerConfig;
|
||||
use backend_service::config::ServerConfig;
|
||||
use lib_infra::future::ResultFuture;
|
||||
|
||||
pub trait UserServerAPI {
|
||||
|
@ -3,8 +3,7 @@ use crate::{
|
||||
errors::UserError,
|
||||
services::server::UserServerAPI,
|
||||
};
|
||||
use backend_api::user_request::*;
|
||||
use flowy_net::config::*;
|
||||
use backend_service::{config::*, user_request::*};
|
||||
use lib_infra::future::ResultFuture;
|
||||
|
||||
pub struct UserServer {
|
||||
@ -62,7 +61,7 @@ impl UserServerAPI for UserServer {
|
||||
}
|
||||
|
||||
// use crate::notify::*;
|
||||
// use flowy_net::response::FlowyResponse;
|
||||
// use backend_service::response::FlowyResponse;
|
||||
// use flowy_user_infra::errors::ErrorCode;
|
||||
|
||||
// struct Middleware {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::services::user::{UserSession, UserSessionConfig};
|
||||
use flowy_net::config::ServerConfig;
|
||||
use backend_service::config::ServerConfig;
|
||||
|
||||
pub struct UserSessionBuilder {
|
||||
config: Option<UserSessionConfig>,
|
||||
|
@ -9,6 +9,7 @@ use crate::{
|
||||
notify::*,
|
||||
services::server::{construct_user_server, Server},
|
||||
};
|
||||
use backend_service::config::ServerConfig;
|
||||
use flowy_database::{
|
||||
query_dsl::*,
|
||||
schema::{user_table, user_table::dsl},
|
||||
@ -16,7 +17,6 @@ use flowy_database::{
|
||||
ExpressionMethods,
|
||||
UserDatabaseConnection,
|
||||
};
|
||||
use flowy_net::config::ServerConfig;
|
||||
use lib_infra::kv::KV;
|
||||
use lib_sqlite::ConnectionPool;
|
||||
use lib_ws::{WsController, WsMessageHandler, WsState};
|
||||
|
@ -16,8 +16,7 @@ lib-sqlite = { path = "../lib-sqlite" }
|
||||
lib-infra = { path = "../lib-infra" }
|
||||
dart-notify = { path = "../dart-notify" }
|
||||
lib-ot = { path = "../lib-ot" }
|
||||
flowy-net = { path = "../flowy-net", features = ["flowy_request"] }
|
||||
backend-api = { path = "../backend-api" }
|
||||
backend-service = { path = "../backend-service" }
|
||||
|
||||
parking_lot = "0.11"
|
||||
protobuf = {version = "2.18.0"}
|
||||
|
@ -1,8 +1,8 @@
|
||||
use bytes::Bytes;
|
||||
|
||||
use backend_service::errors::ErrorCode as ServerErrorCode;
|
||||
use flowy_derive::ProtoBuf;
|
||||
use flowy_document::errors::DocError;
|
||||
use flowy_net::errors::ErrorCode as ServerErrorCode;
|
||||
pub use flowy_workspace_infra::errors::ErrorCode;
|
||||
use lib_dispatch::prelude::{EventResponse, ResponseBuilder};
|
||||
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) }
|
||||
}
|
||||
|
||||
impl std::convert::From<flowy_net::errors::ServerError> for WorkspaceError {
|
||||
fn from(error: flowy_net::errors::ServerError) -> Self {
|
||||
impl std::convert::From<backend_service::errors::ServerError> for WorkspaceError {
|
||||
fn from(error: backend_service::errors::ServerError) -> Self {
|
||||
let code = server_error_to_workspace_error(error.code);
|
||||
WorkspaceError::new(code, &error.msg)
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ use crate::{
|
||||
handlers::*,
|
||||
services::{server::construct_workspace_server, AppController, TrashCan, ViewController, WorkspaceController},
|
||||
};
|
||||
use backend_service::config::ServerConfig;
|
||||
use flowy_database::DBConnection;
|
||||
use flowy_document::module::FlowyDocument;
|
||||
use flowy_net::config::ServerConfig;
|
||||
use lib_dispatch::prelude::*;
|
||||
use lib_sqlite::ConnectionPool;
|
||||
use std::sync::Arc;
|
||||
|
@ -14,7 +14,7 @@ use crate::{
|
||||
},
|
||||
errors::WorkspaceError,
|
||||
};
|
||||
use flowy_net::config::ServerConfig;
|
||||
use backend_service::config::ServerConfig;
|
||||
use lib_infra::future::ResultFuture;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -9,8 +9,7 @@ use crate::{
|
||||
notify::{send_dart_notification, WorkspaceNotification},
|
||||
services::server::WorkspaceServerAPI,
|
||||
};
|
||||
use backend_api::{middleware::*, workspace_request::*};
|
||||
use flowy_net::config::ServerConfig;
|
||||
use backend_service::{config::ServerConfig, middleware::*, workspace_request::*};
|
||||
use flowy_workspace_infra::errors::ErrorCode;
|
||||
use lib_infra::future::ResultFuture;
|
||||
|
||||
|
@ -7,7 +7,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
flowy-derive = { path = "../flowy-derive" }
|
||||
flowy-net = { path = "../flowy-net" }
|
||||
backend-service = { path = "../backend-service" }
|
||||
lib-infra = { path = "../lib-infra" }
|
||||
|
||||
tokio-tungstenite = "0.15"
|
||||
|
@ -4,9 +4,9 @@ use crate::{
|
||||
WsMessage,
|
||||
WsModule,
|
||||
};
|
||||
use backend_service::errors::ServerError;
|
||||
use bytes::Bytes;
|
||||
use dashmap::DashMap;
|
||||
use flowy_net::errors::ServerError;
|
||||
use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};
|
||||
use futures_core::{ready, Stream};
|
||||
use lib_infra::retry::{Action, FixedInterval, Retry};
|
||||
|
Loading…
Reference in New Issue
Block a user