mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
move dir
This commit is contained in:
parent
464d5396e6
commit
c77c63a4c2
@ -1,3 +1,11 @@
|
||||
use std::{net::TcpListener, time::Duration};
|
||||
|
||||
use actix::Actor;
|
||||
use actix_identity::{CookieIdentityPolicy, IdentityService};
|
||||
use actix_web::{dev::Server, middleware, web, web::Data, App, HttpServer, Scope};
|
||||
use sqlx::{postgres::PgPoolOptions, PgPool};
|
||||
use tokio::time::interval;
|
||||
|
||||
use crate::{
|
||||
config::{
|
||||
env::{domain, secret, use_https},
|
||||
@ -5,18 +13,18 @@ use crate::{
|
||||
Settings,
|
||||
},
|
||||
context::AppContext,
|
||||
doc_service::router as doc,
|
||||
user_service::router as user,
|
||||
workspace_service::{app::router as app, view::router as view, workspace::router as workspace},
|
||||
ws_service,
|
||||
ws_service::WSServer,
|
||||
service::{
|
||||
doc_service::router as doc,
|
||||
user_service::router as user,
|
||||
workspace_service::{
|
||||
app::router as app,
|
||||
view::router as view,
|
||||
workspace::router as workspace,
|
||||
},
|
||||
ws_service,
|
||||
ws_service::WSServer,
|
||||
},
|
||||
};
|
||||
use actix::Actor;
|
||||
use actix_identity::{CookieIdentityPolicy, IdentityService};
|
||||
use actix_web::{dev::Server, middleware, web, web::Data, App, HttpServer, Scope};
|
||||
use sqlx::{postgres::PgPoolOptions, PgPool};
|
||||
use std::{net::TcpListener, time::Duration};
|
||||
use tokio::time::interval;
|
||||
|
||||
pub struct Application {
|
||||
port: u16,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::ws_service::WSServer;
|
||||
use crate::service::ws_service::WSServer;
|
||||
use actix::Addr;
|
||||
|
||||
use sqlx::PgPool;
|
||||
|
@ -1,37 +0,0 @@
|
||||
use crate::routers::utils::parse_from_payload;
|
||||
use actix_web::{
|
||||
web::{Data, Payload},
|
||||
HttpResponse,
|
||||
};
|
||||
use flowy_document::protobuf::CreateDocParams;
|
||||
use flowy_net::errors::ServerError;
|
||||
use sqlx::PgPool;
|
||||
|
||||
pub async fn create_handler(
|
||||
payload: Payload,
|
||||
_pool: Data<PgPool>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
let _params: CreateDocParams = parse_from_payload(payload).await?;
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub async fn read_handler(
|
||||
_payload: Payload,
|
||||
_pool: Data<PgPool>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub async fn update_handler(
|
||||
_payload: Payload,
|
||||
_pool: Data<PgPool>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub async fn delete_handler(
|
||||
_payload: Payload,
|
||||
_pool: Data<PgPool>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
unimplemented!()
|
||||
}
|
@ -1,11 +1,8 @@
|
||||
pub mod application;
|
||||
pub mod config;
|
||||
mod context;
|
||||
mod doc_service;
|
||||
mod entities;
|
||||
mod middleware;
|
||||
mod routers;
|
||||
mod service;
|
||||
mod sqlx_ext;
|
||||
mod user_service;
|
||||
mod workspace_service;
|
||||
mod ws_service;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::user_service::{LoggedUser, AUTHORIZED_USERS};
|
||||
use crate::service::user_service::{LoggedUser, AUTHORIZED_USERS};
|
||||
use actix_service::{Service, Transform};
|
||||
use actix_web::{
|
||||
dev::{ServiceRequest, ServiceResponse},
|
||||
|
47
backend/src/service/doc_service/router.rs
Normal file
47
backend/src/service/doc_service/router.rs
Normal file
@ -0,0 +1,47 @@
|
||||
use crate::{
|
||||
routers::utils::parse_from_payload,
|
||||
service::doc_service::{create_doc, read_doc, update_doc},
|
||||
};
|
||||
use actix_web::{
|
||||
web::{Data, Payload},
|
||||
HttpResponse,
|
||||
};
|
||||
use flowy_document::protobuf::{CreateDocParams, QueryDocParams, UpdateDocParams};
|
||||
use flowy_net::errors::ServerError;
|
||||
use sqlx::PgPool;
|
||||
|
||||
pub async fn create_handler(
|
||||
payload: Payload,
|
||||
pool: Data<PgPool>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
let params: CreateDocParams = parse_from_payload(payload).await?;
|
||||
let response = create_doc(pool.get_ref(), params).await?;
|
||||
Ok(response.into())
|
||||
}
|
||||
|
||||
pub async fn read_handler(
|
||||
payload: Payload,
|
||||
pool: Data<PgPool>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
let params: QueryDocParams = parse_from_payload(payload).await?;
|
||||
let response = read_doc(pool.get_ref(), params).await?;
|
||||
Ok(response.into())
|
||||
}
|
||||
|
||||
pub async fn update_handler(
|
||||
payload: Payload,
|
||||
pool: Data<PgPool>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
let params: UpdateDocParams = parse_from_payload(payload).await?;
|
||||
let response = update_doc(pool.get_ref(), params).await?;
|
||||
Ok(response.into())
|
||||
}
|
||||
|
||||
pub async fn delete_handler(
|
||||
payload: Payload,
|
||||
pool: Data<PgPool>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
let params: QueryDocParams = parse_from_payload(payload).await?;
|
||||
let response = read_doc(pool.get_ref(), params).await?;
|
||||
Ok(response.into())
|
||||
}
|
4
backend/src/service/mod.rs
Normal file
4
backend/src/service/mod.rs
Normal file
@ -0,0 +1,4 @@
|
||||
pub mod doc_service;
|
||||
pub mod user_service;
|
||||
pub mod workspace_service;
|
||||
pub mod ws_service;
|
@ -1,14 +1,7 @@
|
||||
use super::AUTHORIZED_USERS;
|
||||
use crate::{
|
||||
entities::{token::Token, user::UserTable},
|
||||
sqlx_ext::DBTransaction,
|
||||
user_service::{hash_password, verify_password, LoggedUser},
|
||||
workspace_service::user_default::create_default_workspace,
|
||||
};
|
||||
|
||||
use crate::sqlx_ext::{map_sqlx_error, SqlBuilder};
|
||||
use anyhow::Context;
|
||||
use chrono::Utc;
|
||||
use sqlx::{PgPool, Postgres};
|
||||
|
||||
use flowy_net::{
|
||||
errors::{invalid_params, ErrorCode, ServerError},
|
||||
response::FlowyResponse,
|
||||
@ -24,7 +17,17 @@ use flowy_user::{
|
||||
UserProfile,
|
||||
},
|
||||
};
|
||||
use sqlx::{PgPool, Postgres};
|
||||
|
||||
use crate::{
|
||||
entities::{token::Token, user::UserTable},
|
||||
service::{
|
||||
user_service::{hash_password, verify_password, LoggedUser},
|
||||
workspace_service::user_default::create_default_workspace,
|
||||
},
|
||||
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
||||
};
|
||||
|
||||
use super::AUTHORIZED_USERS;
|
||||
|
||||
pub async fn sign_in(pool: &PgPool, params: SignInParams) -> Result<SignInResponse, ServerError> {
|
||||
let email =
|
@ -1,13 +1,18 @@
|
||||
use crate::routers::utils::parse_from_payload;
|
||||
use actix_identity::Identity;
|
||||
use actix_web::{
|
||||
web::{Data, Payload},
|
||||
HttpRequest,
|
||||
HttpResponse,
|
||||
};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use flowy_net::{errors::ServerError, response::FlowyResponse};
|
||||
use flowy_user::protobuf::{SignInParams, SignUpParams, UpdateUserParams};
|
||||
|
||||
use crate::{
|
||||
entities::token::Token,
|
||||
user_service::{
|
||||
routers::utils::parse_from_payload,
|
||||
service::user_service::{
|
||||
get_user_profile,
|
||||
register_user,
|
||||
set_user_profile,
|
||||
@ -16,10 +21,6 @@ use crate::{
|
||||
LoggedUser,
|
||||
},
|
||||
};
|
||||
use actix_identity::Identity;
|
||||
use flowy_net::{errors::ServerError, response::FlowyResponse};
|
||||
use flowy_user::protobuf::{SignInParams, SignUpParams, UpdateUserParams};
|
||||
use sqlx::PgPool;
|
||||
|
||||
pub async fn sign_in_handler(
|
||||
payload: Payload,
|
@ -1,14 +1,12 @@
|
||||
use flowy_net::{errors::ServerError, response::FlowyResponse};
|
||||
|
||||
use crate::{
|
||||
entities::workspace::{AppTable, APP_TABLE},
|
||||
sqlx_ext::{map_sqlx_error, SqlBuilder},
|
||||
user_service::LoggedUser,
|
||||
workspace_service::{app::sql_builder::*, view::read_views_belong_to_id},
|
||||
};
|
||||
use anyhow::Context;
|
||||
use chrono::Utc;
|
||||
use flowy_net::errors::invalid_params;
|
||||
use protobuf::Message;
|
||||
use sqlx::{postgres::PgArguments, PgPool, Postgres};
|
||||
|
||||
use flowy_net::{
|
||||
errors::{invalid_params, ServerError},
|
||||
response::FlowyResponse,
|
||||
};
|
||||
use flowy_workspace::{
|
||||
entities::{
|
||||
app::parser::{AppDesc, AppName},
|
||||
@ -16,8 +14,15 @@ use flowy_workspace::{
|
||||
},
|
||||
protobuf::{App, CreateAppParams, QueryAppParams, RepeatedView, UpdateAppParams},
|
||||
};
|
||||
use protobuf::Message;
|
||||
use sqlx::{postgres::PgArguments, PgPool, Postgres};
|
||||
|
||||
use crate::{
|
||||
entities::workspace::{AppTable, APP_TABLE},
|
||||
service::{
|
||||
user_service::LoggedUser,
|
||||
workspace_service::{app::sql_builder::*, view::read_views_belong_to_id},
|
||||
},
|
||||
sqlx_ext::{map_sqlx_error, SqlBuilder},
|
||||
};
|
||||
|
||||
pub(crate) async fn create_app(
|
||||
pool: &PgPool,
|
@ -1,13 +1,9 @@
|
||||
use crate::{
|
||||
routers::utils::parse_from_payload,
|
||||
workspace_service::app::app::{create_app, delete_app, read_app, update_app},
|
||||
};
|
||||
|
||||
use crate::user_service::LoggedUser;
|
||||
use actix_web::{
|
||||
web::{Data, Payload},
|
||||
HttpResponse,
|
||||
};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use flowy_net::errors::ServerError;
|
||||
use flowy_workspace::protobuf::{
|
||||
CreateAppParams,
|
||||
@ -15,7 +11,14 @@ use flowy_workspace::protobuf::{
|
||||
QueryAppParams,
|
||||
UpdateAppParams,
|
||||
};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::{
|
||||
routers::utils::parse_from_payload,
|
||||
service::{
|
||||
user_service::LoggedUser,
|
||||
workspace_service::app::app::{create_app, delete_app, read_app, update_app},
|
||||
},
|
||||
};
|
||||
|
||||
pub async fn create_handler(
|
||||
payload: Payload,
|
@ -1,15 +1,15 @@
|
||||
use flowy_net::errors::ServerError;
|
||||
use flowy_workspace::protobuf::{App, View, ViewType, Workspace};
|
||||
|
||||
use crate::{
|
||||
sqlx_ext::{map_sqlx_error, DBTransaction},
|
||||
workspace_service::{
|
||||
service::workspace_service::{
|
||||
app::sql_builder::Builder as AppBuilder,
|
||||
view::sql_builder::Builder as ViewBuilder,
|
||||
workspace::sql_builder::Builder as WorkspaceBuilder,
|
||||
},
|
||||
sqlx_ext::{map_sqlx_error, DBTransaction},
|
||||
};
|
||||
|
||||
use flowy_net::errors::ServerError;
|
||||
use flowy_workspace::protobuf::{App, View, ViewType, Workspace};
|
||||
|
||||
pub async fn create_default_workspace(
|
||||
transaction: &mut DBTransaction<'_>,
|
||||
user_id: &str,
|
@ -1,12 +1,9 @@
|
||||
use crate::{
|
||||
routers::utils::parse_from_payload,
|
||||
workspace_service::view::{create_view, delete_view, read_view, update_view},
|
||||
};
|
||||
|
||||
use actix_web::{
|
||||
web::{Data, Payload},
|
||||
HttpResponse,
|
||||
};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use flowy_net::errors::ServerError;
|
||||
use flowy_workspace::protobuf::{
|
||||
CreateViewParams,
|
||||
@ -14,7 +11,11 @@ use flowy_workspace::protobuf::{
|
||||
QueryViewParams,
|
||||
UpdateViewParams,
|
||||
};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::{
|
||||
routers::utils::parse_from_payload,
|
||||
service::workspace_service::view::{create_view, delete_view, read_view, update_view},
|
||||
};
|
||||
|
||||
pub async fn create_handler(
|
||||
payload: Payload,
|
@ -1,10 +1,7 @@
|
||||
use crate::{
|
||||
entities::workspace::ViewTable,
|
||||
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
||||
workspace_service::view::sql_builder::*,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use chrono::Utc;
|
||||
use sqlx::{postgres::PgArguments, PgPool, Postgres};
|
||||
|
||||
use flowy_net::{
|
||||
errors::{invalid_params, ServerError},
|
||||
response::FlowyResponse,
|
||||
@ -17,8 +14,11 @@ use flowy_workspace::{
|
||||
protobuf::{CreateViewParams, QueryViewParams, RepeatedView, UpdateViewParams, View},
|
||||
};
|
||||
|
||||
use crate::entities::workspace::VIEW_TABLE;
|
||||
use sqlx::{postgres::PgArguments, PgPool, Postgres};
|
||||
use crate::{
|
||||
entities::workspace::{ViewTable, VIEW_TABLE},
|
||||
service::workspace_service::view::sql_builder::*,
|
||||
sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},
|
||||
};
|
||||
|
||||
pub(crate) async fn create_view(
|
||||
pool: &PgPool,
|
@ -1,18 +1,9 @@
|
||||
use crate::{
|
||||
routers::utils::parse_from_payload,
|
||||
workspace_service::workspace::{
|
||||
create_workspace,
|
||||
delete_workspace,
|
||||
read_workspaces,
|
||||
update_workspace,
|
||||
},
|
||||
};
|
||||
|
||||
use crate::user_service::LoggedUser;
|
||||
use actix_web::{
|
||||
web::{Data, Payload},
|
||||
HttpResponse,
|
||||
};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use flowy_net::errors::ServerError;
|
||||
use flowy_workspace::protobuf::{
|
||||
CreateWorkspaceParams,
|
||||
@ -20,7 +11,19 @@ use flowy_workspace::protobuf::{
|
||||
QueryWorkspaceParams,
|
||||
UpdateWorkspaceParams,
|
||||
};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::{
|
||||
routers::utils::parse_from_payload,
|
||||
service::{
|
||||
user_service::LoggedUser,
|
||||
workspace_service::workspace::{
|
||||
create_workspace,
|
||||
delete_workspace,
|
||||
read_workspaces,
|
||||
update_workspace,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
pub async fn create_handler(
|
||||
payload: Payload,
|
@ -1,22 +1,25 @@
|
||||
use super::sql_builder::Builder;
|
||||
use crate::{entities::workspace::WorkspaceTable, sqlx_ext::*};
|
||||
use anyhow::Context;
|
||||
use sqlx::{postgres::PgArguments, PgPool, Postgres};
|
||||
|
||||
use flowy_net::{
|
||||
errors::{invalid_params, ServerError},
|
||||
response::FlowyResponse,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
entities::workspace::{AppTable, WORKSPACE_TABLE},
|
||||
user_service::LoggedUser,
|
||||
workspace_service::{view::read_views_belong_to_id, workspace::sql_builder::*},
|
||||
};
|
||||
use flowy_workspace::{
|
||||
entities::workspace::parser::{WorkspaceDesc, WorkspaceId, WorkspaceName},
|
||||
protobuf::{App, CreateWorkspaceParams, RepeatedApp, RepeatedWorkspace, UpdateWorkspaceParams},
|
||||
};
|
||||
use sqlx::{postgres::PgArguments, PgPool, Postgres};
|
||||
|
||||
use crate::{
|
||||
entities::workspace::{AppTable, WorkspaceTable, WORKSPACE_TABLE},
|
||||
service::{
|
||||
user_service::LoggedUser,
|
||||
workspace_service::{view::read_views_belong_to_id, workspace::sql_builder::*},
|
||||
},
|
||||
sqlx_ext::*,
|
||||
};
|
||||
|
||||
use super::sql_builder::Builder;
|
||||
|
||||
pub(crate) async fn create_workspace(
|
||||
pool: &PgPool,
|
@ -1,4 +1,4 @@
|
||||
use crate::ws_service::ClientMessage;
|
||||
use crate::service::ws_service::ClientMessage;
|
||||
use actix::{Message, Recipient};
|
||||
use flowy_net::errors::ServerError;
|
||||
use serde::{Deserialize, Serialize};
|
@ -1,4 +1,4 @@
|
||||
use crate::ws_service::entities::SessionId;
|
||||
use crate::service::ws_service::entities::SessionId;
|
||||
use actix::Message;
|
||||
use bytes::Bytes;
|
||||
use std::fmt::Formatter;
|
@ -1,4 +1,4 @@
|
||||
use crate::ws_service::{entities::SessionId, WSClient, WSServer};
|
||||
use crate::service::ws_service::{entities::SessionId, WSClient, WSServer};
|
||||
use actix::Addr;
|
||||
|
||||
use actix_web::{
|
@ -1,12 +1,5 @@
|
||||
use crate::{
|
||||
config::{HEARTBEAT_INTERVAL, PING_TIMEOUT},
|
||||
ws_service::{
|
||||
entities::{Connect, Disconnect, SessionId},
|
||||
ClientMessage,
|
||||
MessageData,
|
||||
WSServer,
|
||||
},
|
||||
};
|
||||
use std::time::Instant;
|
||||
|
||||
use actix::{
|
||||
fut,
|
||||
Actor,
|
||||
@ -20,9 +13,17 @@ use actix::{
|
||||
StreamHandler,
|
||||
WrapFuture,
|
||||
};
|
||||
|
||||
use actix_web_actors::{ws, ws::Message::Text};
|
||||
use std::time::Instant;
|
||||
|
||||
use crate::{
|
||||
config::{HEARTBEAT_INTERVAL, PING_TIMEOUT},
|
||||
service::ws_service::{
|
||||
entities::{Connect, Disconnect, SessionId},
|
||||
ClientMessage,
|
||||
MessageData,
|
||||
WSServer,
|
||||
},
|
||||
};
|
||||
|
||||
pub struct WSClient {
|
||||
sid: SessionId,
|
@ -1,4 +1,4 @@
|
||||
use crate::ws_service::{
|
||||
use crate::service::ws_service::{
|
||||
entities::{Connect, Disconnect, Session, SessionId},
|
||||
ClientMessage,
|
||||
};
|
0
backend/tests/api/doc.rs
Normal file
0
backend/tests/api/doc.rs
Normal file
@ -1,3 +1,4 @@
|
||||
mod auth;
|
||||
mod doc;
|
||||
mod helper;
|
||||
mod workspace;
|
||||
|
Loading…
Reference in New Issue
Block a user