Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/update actix web #2

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,261 changes: 783 additions & 478 deletions scheduler/Cargo.lock

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions scheduler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ members = [
nettu_scheduler_api = { path = "./crates/api" }
nettu_scheduler_domain = { path = "./crates/domain" }
nettu_scheduler_infra = { path = "./crates/infra" }
actix-web = "4.0.0-beta.8"
actix-web = "4.8"
tracing = "0.1.19"
tracing-subscriber = { version = "0.2.12", features = ["registry", "env-filter"] }
tracing-subscriber = { version = "0.2.12", features = [
"registry",
"env-filter",
] }
tracing-bunyan-formatter = "0.2.4"
tracing-log = "0.1.1"
openssl-probe = "0.1.2"
Expand Down
12 changes: 6 additions & 6 deletions scheduler/crates/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ nettu_scheduler_domain = { path = "../domain" }
nettu_scheduler_infra = { path = "../infra" }
serde = { version = "1.0", features = ["derive"] }
futures = "0.3"
actix-web = "4.0.0-beta.8"
actix-cors = "0.6.0-beta.2"
awc = "3.0.0-beta.7"
actix-web = "4.8"
actix-cors = "0.7"
awc = "3.5"
async-trait = "0.1.42"
rrule="0.5.8"
rrule = "0.5.8"
chrono = { version = "0.4.19", features = ["serde"] }
chrono-tz = "0.5.3"
anyhow = "1.0.0"
jsonwebtoken = "7"
thiserror = "1.0"
tracing = "0.1.25"
tracing-actix-web = "0.4.0-beta.10"
tracing-actix-web = "0.7.11"
tracing-futures = "0.2.5"

[dev-dependencies]
serial_test = "*"
serial_test = "*"
4 changes: 2 additions & 2 deletions scheduler/crates/api/src/account/add_account_integration.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::shared::usecase::{execute, UseCase};
use crate::{error::NettuError, shared::auth::protect_account_route};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::add_account_integration::{APIResponse, RequestBody};
use nettu_scheduler_domain::{Account, AccountIntegration, IntegrationProvider};
use nettu_scheduler_infra::NettuContext;

pub async fn add_account_integration_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
body: web::Json<RequestBody>,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
Expand Down
4 changes: 2 additions & 2 deletions scheduler/crates/api/src/account/delete_account_webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use super::set_account_webhook::SetAccountWebhookUseCase;
use crate::error::NettuError;
use crate::shared::auth::protect_account_route;
use crate::shared::usecase::execute;
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::delete_account_webhook::APIResponse;
use nettu_scheduler_infra::NettuContext;

pub async fn delete_account_webhook_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
let account = protect_account_route(&http_req, &ctx).await?;
Expand Down
4 changes: 2 additions & 2 deletions scheduler/crates/api/src/account/get_account.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::error::NettuError;
use crate::shared::auth::protect_account_route;
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::get_account::APIResponse;
use nettu_scheduler_infra::NettuContext;

pub async fn get_account_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
let account = protect_account_route(&http_req, &ctx).await?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::shared::usecase::{execute, UseCase};
use crate::{error::NettuError, shared::auth::protect_account_route};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::remove_account_integration::{APIResponse, PathParams};
use nettu_scheduler_domain::{Account, IntegrationProvider};
use nettu_scheduler_infra::NettuContext;

pub async fn remove_account_integration_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
mut path: web::Path<PathParams>,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
Expand Down
4 changes: 2 additions & 2 deletions scheduler/crates/api/src/account/set_account_pub_key.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::shared::usecase::{execute, UseCase};
use crate::{error::NettuError, shared::auth::protect_account_route};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::set_account_pub_key::{APIResponse, RequestBody};
use nettu_scheduler_domain::{Account, PEMKey};
use nettu_scheduler_infra::NettuContext;

pub async fn set_account_pub_key_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
ctx: web::Data<NettuContext>,
body: web::Json<RequestBody>,
) -> Result<HttpResponse, NettuError> {
Expand Down
4 changes: 2 additions & 2 deletions scheduler/crates/api/src/account/set_account_webhook.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::shared::usecase::{execute, UseCase};
use crate::{error::NettuError, shared::auth::protect_account_route};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::set_account_webhook::{APIResponse, RequestBody};
use nettu_scheduler_domain::Account;
use nettu_scheduler_infra::NettuContext;

pub async fn set_account_webhook_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
ctx: web::Data<NettuContext>,
body: web::Json<RequestBody>,
) -> Result<HttpResponse, NettuError> {
Expand Down
4 changes: 2 additions & 2 deletions scheduler/crates/api/src/calendar/add_sync_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
error::NettuError,
shared::usecase::{execute, UseCase},
};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::add_sync_calendar::{APIResponse, PathParams, RequestBody};
use nettu_scheduler_domain::IntegrationProvider;
use nettu_scheduler_domain::{
Expand All @@ -17,7 +17,7 @@ use nettu_scheduler_infra::{
};

pub async fn add_sync_calendar_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path_params: web::Path<PathParams>,
body: web::Json<RequestBody>,
ctx: web::Data<NettuContext>,
Expand Down
6 changes: 3 additions & 3 deletions scheduler/crates/api/src/calendar/create_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use crate::{
error::NettuError,
shared::usecase::{execute, UseCase},
};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use chrono::Weekday;
use chrono_tz::Tz;
use nettu_scheduler_api_structs::create_calendar::{APIResponse, PathParams, RequestBody};
use nettu_scheduler_domain::{Calendar, CalendarSettings, Metadata, ID};
use nettu_scheduler_infra::NettuContext;

pub async fn create_calendar_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path_params: web::Path<PathParams>,
body: web::Json<RequestBody>,
ctx: web::Data<NettuContext>,
Expand All @@ -38,7 +38,7 @@ pub async fn create_calendar_admin_controller(
}

pub async fn create_calendar_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
body: web::Json<RequestBody>,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
Expand Down
6 changes: 3 additions & 3 deletions scheduler/crates/api/src/calendar/delete_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use crate::shared::{
usecase::{execute, execute_with_policy, PermissionBoundary},
};
use crate::{error::NettuError, shared::usecase::UseCase};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::delete_calendar::{APIResponse, PathParams};
use nettu_scheduler_domain::{Calendar, ID};
use nettu_scheduler_infra::NettuContext;

pub async fn delete_calendar_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path: web::Path<PathParams>,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
Expand All @@ -28,7 +28,7 @@ pub async fn delete_calendar_admin_controller(
}

pub async fn delete_calendar_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path: web::Path<PathParams>,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
Expand Down
2 changes: 1 addition & 1 deletion scheduler/crates/api/src/calendar/get_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use nettu_scheduler_domain::{Calendar, ID};
use nettu_scheduler_infra::NettuContext;

pub async fn get_calendar_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path: web::Path<PathParams>,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
Expand Down
2 changes: 1 addition & 1 deletion scheduler/crates/api/src/calendar/get_calendar_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use nettu_scheduler_domain::{Calendar, EventWithInstances, TimeSpan, ID};
use nettu_scheduler_infra::NettuContext;

pub async fn get_calendar_events_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
query_params: web::Query<QueryParams>,
path: web::Path<PathParams>,
ctx: web::Data<NettuContext>,
Expand Down
2 changes: 1 addition & 1 deletion scheduler/crates/api/src/calendar/get_google_calendars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use nettu_scheduler_domain::{
use nettu_scheduler_infra::{google_calendar::GoogleCalendarProvider, NettuContext};

pub async fn get_google_calendars_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path: web::Path<PathParams>,
query: web::Query<QueryParams>,
ctx: web::Data<NettuContext>,
Expand Down
2 changes: 1 addition & 1 deletion scheduler/crates/api/src/calendar/get_outlook_calendars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use nettu_scheduler_domain::{
use nettu_scheduler_infra::{outlook_calendar::OutlookCalendarProvider, NettuContext};

pub async fn get_outlook_calendars_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path: web::Path<PathParams>,
query: web::Query<QueryParams>,
ctx: web::Data<NettuContext>,
Expand Down
4 changes: 2 additions & 2 deletions scheduler/crates/api/src/calendar/remove_sync_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
error::NettuError,
shared::usecase::{execute, UseCase},
};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::remove_sync_calendar::{APIResponse, PathParams, RequestBody};
use nettu_scheduler_domain::IntegrationProvider;
use nettu_scheduler_domain::{User, ID};
Expand All @@ -20,7 +20,7 @@ fn error_handler(e: UseCaseError) -> NettuError {
}

pub async fn remove_sync_calendar_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path_params: web::Path<PathParams>,
body: web::Json<RequestBody>,
ctx: web::Data<NettuContext>,
Expand Down
6 changes: 3 additions & 3 deletions scheduler/crates/api/src/calendar/update_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ use crate::shared::{
usecase::{execute, execute_with_policy, PermissionBoundary, UseCase},
};
use crate::{error::NettuError, shared::auth::protect_route};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use chrono::Weekday;
use chrono_tz::Tz;
use nettu_scheduler_api_structs::update_calendar::{APIResponse, PathParams, RequestBody};
use nettu_scheduler_domain::{Calendar, Metadata, User, ID};
use nettu_scheduler_infra::NettuContext;

pub async fn update_calendar_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
ctx: web::Data<NettuContext>,
path: web::Path<PathParams>,
body: web::Json<RequestBody>,
Expand All @@ -37,7 +37,7 @@ pub async fn update_calendar_admin_controller(
}

pub async fn update_calendar_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
ctx: web::Data<NettuContext>,
mut path: web::Path<PathParams>,
body: web::Json<RequestBody>,
Expand Down
6 changes: 3 additions & 3 deletions scheduler/crates/api/src/event/create_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ use crate::shared::{
auth::{account_can_modify_user, protect_account_route, protect_route, Permission},
usecase::{execute, execute_with_policy, PermissionBoundary, Subscriber, UseCase},
};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::create_event::*;
use nettu_scheduler_domain::{
CalendarEvent, CalendarEventReminder, Metadata, RRuleOptions, User, ID,
};
use nettu_scheduler_infra::NettuContext;

pub async fn create_event_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path_params: web::Path<PathParams>,
body: web::Json<RequestBody>,
ctx: web::Data<NettuContext>,
Expand Down Expand Up @@ -41,7 +41,7 @@ pub async fn create_event_admin_controller(
}

pub async fn create_event_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
body: web::Json<RequestBody>,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
Expand Down
6 changes: 3 additions & 3 deletions scheduler/crates/api/src/schedule/create_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ use crate::{
usecase::{execute_with_policy, PermissionBoundary},
},
};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use chrono_tz::Tz;
use nettu_scheduler_api_structs::create_schedule::*;
use nettu_scheduler_domain::{Metadata, Schedule, ScheduleRule, ID};
use nettu_scheduler_infra::NettuContext;

pub async fn create_schedule_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path_params: web::Path<PathParams>,
body_params: web::Json<RequestBody>,
ctx: web::Data<NettuContext>,
Expand All @@ -39,7 +39,7 @@ pub async fn create_schedule_admin_controller(
}

pub async fn create_schedule_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
body_params: web::Json<RequestBody>,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
Expand Down
6 changes: 3 additions & 3 deletions scheduler/crates/api/src/schedule/delete_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use crate::shared::{
usecase::{execute, execute_with_policy, PermissionBoundary},
};
use crate::{error::NettuError, shared::usecase::UseCase};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use nettu_scheduler_api_structs::delete_schedule::*;
use nettu_scheduler_domain::{Schedule, ID};
use nettu_scheduler_infra::NettuContext;

pub async fn delete_schedule_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path: web::Path<PathParams>,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
Expand All @@ -28,7 +28,7 @@ pub async fn delete_schedule_admin_controller(
}

pub async fn delete_schedule_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path: web::Path<PathParams>,
ctx: web::Data<NettuContext>,
) -> Result<HttpResponse, NettuError> {
Expand Down
6 changes: 3 additions & 3 deletions scheduler/crates/api/src/schedule/update_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ use crate::{
usecase::{execute_with_policy, PermissionBoundary},
},
};
use actix_web::{web, HttpResponse};
use actix_web::{web, HttpRequest, HttpResponse};
use chrono_tz::Tz;
use nettu_scheduler_api_structs::update_schedule::*;
use nettu_scheduler_domain::{Metadata, Schedule, ScheduleRule, ID};
use nettu_scheduler_infra::NettuContext;

pub async fn update_schedule_admin_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
path: web::Path<PathParams>,
body: web::Json<RequestBody>,
ctx: web::Data<NettuContext>,
Expand All @@ -40,7 +40,7 @@ pub async fn update_schedule_admin_controller(
}

pub async fn update_schedule_controller(
http_req: web::HttpRequest,
http_req: HttpRequest,
ctx: web::Data<NettuContext>,
mut path: web::Path<PathParams>,
body: web::Json<RequestBody>,
Expand Down