diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2005f0744..a9d78ff89 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -247,6 +247,8 @@ jobs: path: ${{ fromJson(needs.examples-matrix.outputs.path_matrix) }} steps: - uses: actions/checkout@v3 + - if: ${{ contains(matrix.path, 'tonic_example') }} + uses: arduino/setup-protoc@v1 - uses: dtolnay/rust-toolchain@master with: toolchain: stable diff --git a/examples/actix_example/api/Cargo.toml b/examples/actix_example/api/Cargo.toml index 18374e707..44d4f3a03 100644 --- a/examples/actix_example/api/Cargo.toml +++ b/examples/actix_example/api/Cargo.toml @@ -9,12 +9,12 @@ publish = false actix-example-service = { path = "../service" } actix-files = "0.6" actix-http = "3" -actix-rt = "2.7" +actix-rt = "2.8" actix-service = "2" actix-web = "4" -tera = "1.15.0" +tera = "1.19.0" dotenvy = "0.15" -listenfd = "0.5" +listenfd = "1" serde = "1" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } entity = { path = "../entity" } diff --git a/examples/axum_example/api/Cargo.toml b/examples/axum_example/api/Cargo.toml index 541034e39..de7462e48 100644 --- a/examples/axum_example/api/Cargo.toml +++ b/examples/axum_example/api/Cargo.toml @@ -7,15 +7,15 @@ publish = false [dependencies] axum-example-service = { path = "../service" } -tokio = { version = "1.23.0", features = ["full"] } -axum = "0.6.1" +tokio = { version = "1.29.0", features = ["full"] } +axum = "0.6.19" tower = "0.4.13" -tower-http = { version = "0.3.5", features = ["fs"] } -tower-cookies = "0.8.0" -anyhow = "1.0.66" -dotenvy = "0.15.6" -serde = "1.0.149" -serde_json = "1.0.89" +tower-http = { version = "0.4.3", features = ["fs"] } +tower-cookies = "0.9.0" +anyhow = "1.0.71" +dotenvy = "0.15.7" +serde = "1.0.175" +serde_json = "1.0.102" tera = "1.17.1" tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } entity = { path = "../entity" } diff --git a/examples/axum_example/api/src/lib.rs b/examples/axum_example/api/src/lib.rs index 324840337..28a7572b9 100644 --- a/examples/axum_example/api/src/lib.rs +++ b/examples/axum_example/api/src/lib.rs @@ -53,7 +53,7 @@ async fn start() -> anyhow::Result<()> { env!("CARGO_MANIFEST_DIR"), "/static" ))) - .handle_error(|error: std::io::Error| async move { + .handle_error(|error| async move { ( StatusCode::INTERNAL_SERVER_ERROR, format!("Unhandled internal error: {error}"), diff --git a/examples/basic/Cargo.toml b/examples/basic/Cargo.toml index 4c36d6cc9..36f258443 100644 --- a/examples/basic/Cargo.toml +++ b/examples/basic/Cargo.toml @@ -8,9 +8,9 @@ edition = "2021" publish = false [dependencies] -async-std = { version = "1.9", features = [ "attributes", "tokio1" ] } +async-std = { version = "1.12", features = [ "attributes", "tokio1" ] } sea-orm = { path = "../../", features = [ "sqlx-all", "runtime-async-std-native-tls" ] } serde_json = { version = "1" } futures = { version = "0.3" } async-stream = { version = "0.3" } -futures-util = { version = "0.3" } +futures-util = { version = "0.3" } \ No newline at end of file diff --git a/examples/graphql_example/api/Cargo.toml b/examples/graphql_example/api/Cargo.toml index 1115d8396..2ffb5544c 100644 --- a/examples/graphql_example/api/Cargo.toml +++ b/examples/graphql_example/api/Cargo.toml @@ -7,9 +7,10 @@ publish = false [dependencies] graphql-example-service = { path = "../service" } -tokio = { version = "1.0", features = ["full"] } -axum = "0.5.1" -dotenvy = "0.15.0" -async-graphql-axum = "4.0.6" +tokio = { version = "1.29", features = ["full"] } +axum = "0.6.18" +axum-macros = "0.3" +dotenvy = "0.15.7" +async-graphql-axum = "5.0.10" entity = { path = "../entity" } -migration = { path = "../migration" } +migration = { path = "../migration" } \ No newline at end of file diff --git a/examples/graphql_example/api/src/lib.rs b/examples/graphql_example/api/src/lib.rs index 85275fcbe..51cbc68a6 100644 --- a/examples/graphql_example/api/src/lib.rs +++ b/examples/graphql_example/api/src/lib.rs @@ -6,17 +6,19 @@ use entity::async_graphql; use async_graphql::http::{playground_source, GraphQLPlaygroundConfig}; use async_graphql_axum::{GraphQLRequest, GraphQLResponse}; use axum::{ - extract::Extension, + extract::State, response::{Html, IntoResponse}, routing::get, Router, }; +use axum_macros::debug_handler; use graphql::schema::{build_schema, AppSchema}; #[cfg(debug_assertions)] use dotenvy::dotenv; -async fn graphql_handler(schema: Extension, req: GraphQLRequest) -> GraphQLResponse { +#[debug_handler] +async fn graphql_handler(schema: State, req: GraphQLRequest) -> GraphQLResponse { schema.execute(req.into_inner()).await.into() } @@ -38,7 +40,7 @@ pub async fn main() { "/api/graphql", get(graphql_playground).post(graphql_handler), ) - .layer(Extension(schema)); + .with_state(schema); println!("Playground: http://localhost:3000/api/graphql"); diff --git a/examples/graphql_example/entity/Cargo.toml b/examples/graphql_example/entity/Cargo.toml index 1c6b5a5b5..74812d24c 100644 --- a/examples/graphql_example/entity/Cargo.toml +++ b/examples/graphql_example/entity/Cargo.toml @@ -12,7 +12,7 @@ path = "src/lib.rs" serde = { version = "1", features = ["derive"] } [dependencies.async-graphql] -version = "4.0.6" +version = "5.0.10" [dependencies.sea-orm] path = "../../../" # remove this line in your own project diff --git a/examples/jsonrpsee_example/api/Cargo.toml b/examples/jsonrpsee_example/api/Cargo.toml index fc8883917..32693934e 100644 --- a/examples/jsonrpsee_example/api/Cargo.toml +++ b/examples/jsonrpsee_example/api/Cargo.toml @@ -6,14 +6,14 @@ publish = false [dependencies] jsonrpsee-example-service = { path = "../service" } -jsonrpsee = { version = "0.8.0", features = ["full"] } -jsonrpsee-core = "0.9.0" -tokio = { version = "1.8.0", features = ["full"] } +jsonrpsee = { version = "0.18.2", features = ["full"] } +jsonrpsee-core = "0.18.2" +tokio = { version = "1.29.1", features = ["full"] } serde = { version = "1", features = ["derive"] } dotenvy = "0.15" entity = { path = "../entity" } migration = { path = "../migration" } -anyhow = "1.0.52" -async-trait = "0.1.52" +anyhow = "1.0.71" +async-trait = "0.1.71" log = { version = "0.4", features = ["std"] } simplelog = "0.12" diff --git a/examples/jsonrpsee_example/api/src/lib.rs b/examples/jsonrpsee_example/api/src/lib.rs index de5252384..2e0e27560 100644 --- a/examples/jsonrpsee_example/api/src/lib.rs +++ b/examples/jsonrpsee_example/api/src/lib.rs @@ -1,11 +1,10 @@ use std::env; -use anyhow::anyhow; use entity::post; use jsonrpsee::core::{async_trait, RpcResult}; -use jsonrpsee::http_server::HttpServerBuilder; use jsonrpsee::proc_macros::rpc; -use jsonrpsee::types::error::CallError; +use jsonrpsee::server::ServerBuilder; +use jsonrpsee::types::error::ErrorObjectOwned; use jsonrpsee_example_service::sea_orm::{Database, DatabaseConnection}; use jsonrpsee_example_service::{Mutation, Query}; use log::info; @@ -14,7 +13,7 @@ use simplelog::*; use std::fmt::Display; use std::net::SocketAddr; use tokio::signal::ctrl_c; -use tokio::signal::unix::{signal, SignalKind}; +// use tokio::signal::unix::{signal, SignalKind}; const DEFAULT_POSTS_PER_PAGE: u64 = 5; @@ -88,7 +87,9 @@ where E: Display, { fn internal_call_error(self) -> RpcResult { - self.map_err(|e| jsonrpsee::core::Error::Call(CallError::Failed(anyhow!("{}", e)))) + // Err(ErrorObjectOwned::owned(1, "c", None::<()>)) + // self.map_err(|e| jsonrpsee::core::Error::Call(CallError::Failed(anyhow!("{}", e)))) + self.map_err(|e| ErrorObjectOwned::owned(1, format!("{}", e), None::<()>)) } } @@ -112,8 +113,9 @@ async fn start() -> std::io::Result<()> { let conn = Database::connect(&db_url).await.unwrap(); Migrator::up(&conn, None).await.unwrap(); - let server = HttpServerBuilder::default() + let server = ServerBuilder::default() .build(server_url.parse::().unwrap()) + .await .unwrap(); let rpc_impl = PpcImpl { conn }; @@ -121,12 +123,12 @@ async fn start() -> std::io::Result<()> { let handle = server.start(rpc_impl.into_rpc()).unwrap(); info!("starting listening {}", server_addr); - let mut sig_int = signal(SignalKind::interrupt()).unwrap(); - let mut sig_term = signal(SignalKind::terminate()).unwrap(); + // let mut sig_int = signal(SignalKind::interrupt()).unwrap(); + // let mut sig_term = signal(SignalKind::terminate()).unwrap(); tokio::select! { - _ = sig_int.recv() => info!("receive SIGINT"), - _ = sig_term.recv() => info!("receive SIGTERM"), + // _ = sig_int.recv() => info!("receive SIGINT"), + // _ = sig_term.recv() => info!("receive SIGTERM"), _ = ctrl_c() => info!("receive Ctrl C"), } handle.stop().unwrap(); diff --git a/examples/poem_example/api/Cargo.toml b/examples/poem_example/api/Cargo.toml index 383843f4a..1830c52dd 100644 --- a/examples/poem_example/api/Cargo.toml +++ b/examples/poem_example/api/Cargo.toml @@ -5,11 +5,11 @@ edition = "2021" [dependencies] poem-example-service = { path = "../service" } -tokio = { version = "1.15.0", features = ["macros", "rt-multi-thread"] } -poem = { version = "1.2.33", features = ["static-files"] } +tokio = { version = "1.29.0", features = ["macros", "rt-multi-thread"] } +poem = { version = "1.3.56", features = ["static-files"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } serde = { version = "1", features = ["derive"] } -tera = "1.8.0" +tera = "1.19.0" dotenvy = "0.15" entity = { path = "../entity" } migration = { path = "../migration" } diff --git a/examples/rocket_example/api/Cargo.toml b/examples/rocket_example/api/Cargo.toml index bb2d5cdee..26269bcf2 100644 --- a/examples/rocket_example/api/Cargo.toml +++ b/examples/rocket_example/api/Cargo.toml @@ -20,7 +20,7 @@ rocket_dyn_templates = { version = "0.1.0-rc.1", features = [ serde_json = { version = "1" } entity = { path = "../entity" } migration = { path = "../migration" } -tokio = "1.20.0" +tokio = "1.29.0" [dependencies.sea-orm-rocket] path = "../../../sea-orm-rocket/lib" # remove this line in your own project and uncomment the following line diff --git a/examples/salvo_example/api/Cargo.toml b/examples/salvo_example/api/Cargo.toml index 6635ccbe2..460425de2 100644 --- a/examples/salvo_example/api/Cargo.toml +++ b/examples/salvo_example/api/Cargo.toml @@ -5,11 +5,11 @@ edition = "2021" [dependencies] salvo-example-service = { path = "../service" } -tokio = { version = "1.15.0", features = ["macros", "rt-multi-thread"] } -salvo = { version = "0.27", features = ["affix", "serve-static"] } +tokio = { version = "1.29.0", features = ["macros", "rt-multi-thread"] } +salvo = { version = "0.49", features = ["affix", "serve-static"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } serde = { version = "1", features = ["derive"] } -tera = "1.8.0" +tera = "1.19.0" dotenvy = "0.15" entity = { path = "../entity" } -migration = { path = "../migration" } +migration = { path = "../migration" } \ No newline at end of file diff --git a/examples/salvo_example/api/src/lib.rs b/examples/salvo_example/api/src/lib.rs index 76927c953..6b1aa0fbd 100644 --- a/examples/salvo_example/api/src/lib.rs +++ b/examples/salvo_example/api/src/lib.rs @@ -2,10 +2,8 @@ use std::env; use entity::post; use migration::{Migrator, MigratorTrait}; -use salvo::extra::affix; -use salvo::extra::serve_static::DirHandler; +use salvo::affix; use salvo::prelude::*; -use salvo::writer::Text; use salvo_example_service::{ sea_orm::{Database, DatabaseConnection}, Mutation, Query, @@ -29,7 +27,7 @@ async fn create(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res let conn = &state.conn; let form = req - .extract_form::() + .parse_form::() .await .map_err(|_| StatusError::bad_request())?; @@ -37,7 +35,7 @@ async fn create(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res .await .map_err(|_| StatusError::internal_server_error())?; - res.redirect_found("/"); + Redirect::found("/").render(res); Ok(()) } @@ -114,7 +112,7 @@ async fn update(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res let conn = &state.conn; let id = req.param::("id").unwrap_or_default(); let form = req - .extract_form::() + .parse_form::() .await .map_err(|_| StatusError::bad_request())?; @@ -122,7 +120,7 @@ async fn update(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res .await .map_err(|_| StatusError::internal_server_error())?; - res.redirect_found("/"); + Redirect::found("/").render(res); Ok(()) } @@ -138,7 +136,7 @@ async fn delete(req: &mut Request, depot: &mut Depot, res: &mut Response) -> Res .await .map_err(|_| StatusError::internal_server_error())?; - res.redirect_found("/"); + Redirect::found("/").render(res); Ok(()) } @@ -170,13 +168,13 @@ pub async fn main() { .push(Router::with_path("").get(edit).post(update)) .push(Router::with_path("delete/").post(delete)) .push( - Router::with_path("static/<**>").get(DirHandler::new(concat!( + Router::with_path("static/<**>").get(salvo::prelude::StaticDir::new(concat!( env!("CARGO_MANIFEST_DIR"), "/static" ))), ); - Server::new(TcpListener::bind(&format!("{host}:{port}"))) + Server::new(TcpListener::bind(TcpListener::new(format!("{host}:{port}"))).await) .serve(router) .await; } diff --git a/examples/salvo_example/entity/Cargo.toml b/examples/salvo_example/entity/Cargo.toml index 5171c39b8..dfc8470e8 100644 --- a/examples/salvo_example/entity/Cargo.toml +++ b/examples/salvo_example/entity/Cargo.toml @@ -10,6 +10,7 @@ path = "src/lib.rs" [dependencies] serde = { version = "1", features = ["derive"] } +salvo = { version = "0.49" } [dependencies.sea-orm] path = "../../../" # remove this line in your own project diff --git a/examples/salvo_example/entity/src/post.rs b/examples/salvo_example/entity/src/post.rs index 62cde830c..7223abc74 100644 --- a/examples/salvo_example/entity/src/post.rs +++ b/examples/salvo_example/entity/src/post.rs @@ -1,7 +1,8 @@ +use salvo::prelude::Extractible; use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; -#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Extractible, Deserialize, Serialize)] #[sea_orm(table_name = "posts")] pub struct Model { #[sea_orm(primary_key)] diff --git a/examples/tonic_example/Cargo.toml b/examples/tonic_example/Cargo.toml index 115d1cb0f..c23ee975d 100644 --- a/examples/tonic_example/Cargo.toml +++ b/examples/tonic_example/Cargo.toml @@ -11,8 +11,8 @@ members = [".", "api", "service", "entity", "migration"] [dependencies] tonic-example-api = { path = "api" } -tonic = "0.7" -tokio = { version = "1.17", features = ["macros", "rt-multi-thread", "full"] } +tonic = "0.9.2" +tokio = { version = "1.29", features = ["macros", "rt-multi-thread", "full"] } [[bin]] name = "server" diff --git a/examples/tonic_example/api/Cargo.toml b/examples/tonic_example/api/Cargo.toml index 6d1e650cf..886830347 100644 --- a/examples/tonic_example/api/Cargo.toml +++ b/examples/tonic_example/api/Cargo.toml @@ -6,15 +6,15 @@ publish = false [dependencies] tonic-example-service = { path = "../service" } -tonic = "0.7" -tokio = { version = "1.17", features = ["macros", "rt-multi-thread", "full"] } +tonic = "0.9.2" +tokio = { version = "1.29", features = ["macros", "rt-multi-thread", "full"] } entity = { path = "../entity" } migration = { path = "../migration" } -prost = "0.10.0" +prost = "0.11.9" serde = "1.0" [lib] path = "./src/lib.rs" [build-dependencies] -tonic-build = "0.7" +tonic-build = "0.9.2"