diff --git a/README.md b/README.md index e53aab6e..d0e8e5f4 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Actix Web | [websocket-actorless](./actix-web/websocket-actorless/) | Websocket Actix Web | [cookie-authentication](./actix-web/cookie-authentication/) | Use JWT to authenticate API endpoints | `cargo shuttle init --from shuttle-hq/shuttle-examples --subfolder actix-web/cookie-authentication` Axum | [hello-world](./axum/hello-world/) | Hello World | `cargo shuttle init --template axum` Axum | [metadata](./axum/metadata/) | Simple app that prints the service information such as Shuttle service name | `cargo shuttle init --from shuttle-hq/shuttle-examples --subfolder axum/metadata` +Axum | [qdrant](./axum/qdrant/) | Barebones example of the shuttle-qdrant plugin | `cargo shuttle init --from shuttle-hq/shuttle-examples --subfolder axum/qdrant` Axum | [static-files](./axum/static-files/) | Hello World page that serves static HTML and JS files | `cargo shuttle init --from shuttle-hq/shuttle-examples --subfolder axum/static-files` Axum | [static-next-server](./axum/static-next-server/) | SPA server for serving a apps from frameworks such as Next.js | `cargo shuttle init --from shuttle-hq/shuttle-examples --subfolder axum/static-next-server` Axum | [websocket](./axum/websocket/) | Websocket app that checks the status of Shuttle's API | `cargo shuttle init --from shuttle-hq/shuttle-examples --subfolder axum/websocket` diff --git a/actix-web/cookie-authentication/Cargo.toml b/actix-web/cookie-authentication/Cargo.toml index c5dd81c0..fa578273 100644 --- a/actix-web/cookie-authentication/Cargo.toml +++ b/actix-web/cookie-authentication/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" actix-identity = "0.6.0" actix-session = { version = "0.8.0", features = ["cookie-session"] } actix-web = "4.3.1" -shuttle-actix-web = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-actix-web = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" diff --git a/actix-web/hello-world/Cargo.toml b/actix-web/hello-world/Cargo.toml index be9a0388..e8bed756 100644 --- a/actix-web/hello-world/Cargo.toml +++ b/actix-web/hello-world/Cargo.toml @@ -5,6 +5,6 @@ edition = "2021" [dependencies] actix-web = "4.3.1" -shuttle-actix-web = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-actix-web = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" diff --git a/actix-web/postgres/Cargo.toml b/actix-web/postgres/Cargo.toml index 8b5b5d21..ef5aefba 100644 --- a/actix-web/postgres/Cargo.toml +++ b/actix-web/postgres/Cargo.toml @@ -5,9 +5,9 @@ edition = "2021" [dependencies] actix-web = "4.3.1" -shuttle-actix-web = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-actix-web = "0.37.0" +shuttle-runtime = "0.37.0" serde = "1.0.148" -shuttle-shared-db = { version = "0.36.0", features = ["postgres"] } -sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] } +shuttle-shared-db = { version = "0.37.0", features = ["postgres", "sqlx"] } +sqlx = "0.7.1" tokio = "1.26.0" diff --git a/actix-web/static-files/Cargo.toml b/actix-web/static-files/Cargo.toml index 8b81b824..80cf2a1b 100644 --- a/actix-web/static-files/Cargo.toml +++ b/actix-web/static-files/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" [dependencies] actix-files = "0.6.2" actix-web = "4.3.1" -shuttle-actix-web = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-actix-web = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" diff --git a/actix-web/websocket-actorless/Cargo.toml b/actix-web/websocket-actorless/Cargo.toml index 4c8188b5..2c7761ed 100644 --- a/actix-web/websocket-actorless/Cargo.toml +++ b/actix-web/websocket-actorless/Cargo.toml @@ -13,7 +13,7 @@ futures = "0.3" reqwest = "0.11" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -shuttle-actix-web = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-actix-web = "0.37.0" +shuttle-runtime = "0.37.0" tokio = { version = "1", features = ["rt-multi-thread", "sync"] } tracing = "0.1" diff --git a/axum/hello-world/Cargo.toml b/axum/hello-world/Cargo.toml index f4ddd1b8..2acfaa0e 100644 --- a/axum/hello-world/Cargo.toml +++ b/axum/hello-world/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] axum = "0.7.3" -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.28.2" tracing = "0.1.40" diff --git a/axum/jwt-authentication/Cargo.toml b/axum/jwt-authentication/Cargo.toml index f12fdc05..a98e1724 100644 --- a/axum/jwt-authentication/Cargo.toml +++ b/axum/jwt-authentication/Cargo.toml @@ -10,7 +10,7 @@ jsonwebtoken = "8.3.0" once_cell = "1.18.0" serde = { version = "1.0.188", features = ["derive"] } serde_json = "1.0.107" -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.28.2" tracing-subscriber = "0.3.17" diff --git a/axum/metadata/Cargo.toml b/axum/metadata/Cargo.toml index 6e474faa..78d07289 100644 --- a/axum/metadata/Cargo.toml +++ b/axum/metadata/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] axum = "0.7.3" -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" -shuttle-metadata = "0.36.0" +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" +shuttle-metadata = "0.37.0" tokio = "1.28.2" diff --git a/axum/postgres/Cargo.toml b/axum/postgres/Cargo.toml index 37b42056..7ee3fe9f 100644 --- a/axum/postgres/Cargo.toml +++ b/axum/postgres/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" [dependencies] axum = "0.7.3" serde = { version = "1.0.188", features = ["derive"] } -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" -shuttle-shared-db = { version = "0.36.0", features = ["postgres"] } -sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] } +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" +shuttle-shared-db = { version = "0.37.0", features = ["postgres", "sqlx"] } +sqlx = "0.7.1" tokio = "1.28.2" diff --git a/axum/qdrant/Cargo.toml b/axum/qdrant/Cargo.toml new file mode 100644 index 00000000..2f43d36c --- /dev/null +++ b/axum/qdrant/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "shuttle-axum-qdrant" +version = "0.1.0" +edition = "2021" + +[dependencies] +axum = "0.7.3" +qdrant-client = "1.7.0" +shuttle-axum = "0.37.0" +shuttle-qdrant = "0.37.0" +shuttle-runtime = "0.37.0" +tokio = "1.26.0" diff --git a/axum/qdrant/Secrets.toml b/axum/qdrant/Secrets.toml new file mode 100644 index 00000000..651f7b7a --- /dev/null +++ b/axum/qdrant/Secrets.toml @@ -0,0 +1,3 @@ +# Note that we use gRPC (port 6334) to talk to Qdrant. +CLOUD_URL = 'https://xyz-example.eu-central.aws.cloud.qdrant.io:6334' +API_KEY = 'your_api_key' diff --git a/axum/qdrant/src/main.rs b/axum/qdrant/src/main.rs new file mode 100644 index 00000000..7b87f778 --- /dev/null +++ b/axum/qdrant/src/main.rs @@ -0,0 +1,25 @@ +use axum::{extract::State, routing::get, Router}; +use qdrant_client::prelude::*; +use std::sync::Arc; + +struct AppState { + qdrant: QdrantClient, +} + +async fn list_collections(State(state): State>) -> String { + format!("{:?}\n", state.qdrant.list_collections().await) +} + +#[shuttle_runtime::main] +async fn axum( + #[shuttle_qdrant::Qdrant(cloud_url = "{secrets.CLOUD_URL}", api_key = "{secrets.API_KEY}")] + qdrant: QdrantClient, +) -> shuttle_axum::ShuttleAxum { + let state = Arc::new(AppState { qdrant }); + + let router = Router::new() + .route("/", get(list_collections)) + .with_state(state); + + Ok(router.into()) +} diff --git a/axum/static-files/Cargo.toml b/axum/static-files/Cargo.toml index daeab82c..7b67c21f 100644 --- a/axum/static-files/Cargo.toml +++ b/axum/static-files/Cargo.toml @@ -6,7 +6,7 @@ publish = false [dependencies] axum = "0.7.3" -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.28.2" tower-http = { version = "0.5.0", features = ["fs"] } diff --git a/axum/static-next-server/Cargo.toml b/axum/static-next-server/Cargo.toml index d3d830f7..dd1d5f32 100644 --- a/axum/static-next-server/Cargo.toml +++ b/axum/static-next-server/Cargo.toml @@ -6,7 +6,7 @@ publish = false [dependencies] axum = "0.7.3" -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" tower-http = { version = "0.5.0", features = ["fs"] } diff --git a/axum/turso/Cargo.toml b/axum/turso/Cargo.toml index 0d4a3546..0c444645 100644 --- a/axum/turso/Cargo.toml +++ b/axum/turso/Cargo.toml @@ -5,9 +5,9 @@ edition = "2021" [dependencies] axum = "0.7.3" -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" -shuttle-turso = "0.36.0" +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" +shuttle-turso = "0.37.0" libsql-client = "0.31.0" tokio = "1.26.0" serde = { version = "1.0.164", features = ["derive"] } diff --git a/axum/websocket/Cargo.toml b/axum/websocket/Cargo.toml index 95a5a313..3c46b5ec 100644 --- a/axum/websocket/Cargo.toml +++ b/axum/websocket/Cargo.toml @@ -10,7 +10,7 @@ futures = "0.3.28" reqwest = "0.11.23" serde = { version = "1.0.163", features = ["derive"] } serde_json = "1.0.96" -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.28.2" tower-http = { version = "0.5.0", features = ["fs"] } diff --git a/axum/with-state/Cargo.toml b/axum/with-state/Cargo.toml index 1509649a..b01a6565 100644 --- a/axum/with-state/Cargo.toml +++ b/axum/with-state/Cargo.toml @@ -5,6 +5,6 @@ edition = "2021" [dependencies] axum = "0.7.3" -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" diff --git a/custom-resource/pdo/Cargo.toml b/custom-resource/pdo/Cargo.toml index 84135d31..d0671f6a 100644 --- a/custom-resource/pdo/Cargo.toml +++ b/custom-resource/pdo/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" async-trait = "0.1.56" axum = "0.7.3" serde = { version = "1.0.148", default-features = false, features = ["derive"] } -shuttle-service = "0.36.0" -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-service = "0.37.0" +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.28.2" diff --git a/custom-resource/pdo/src/lib.rs b/custom-resource/pdo/src/lib.rs index dac8efe6..def29563 100644 --- a/custom-resource/pdo/src/lib.rs +++ b/custom-resource/pdo/src/lib.rs @@ -1,15 +1,12 @@ use async_trait::async_trait; use serde::Serialize; -use shuttle_service::Factory; -use shuttle_service::ResourceBuilder; -use shuttle_service::Type; +use shuttle_service::{resource::Type, Error, Factory, IntoResource, ResourceBuilder}; -#[derive(Serialize)] +#[derive(Default, Serialize)] pub struct Builder { name: String, } -#[derive(Clone)] pub struct Pdo { pub name: String, } @@ -23,33 +20,24 @@ impl Builder { } #[async_trait] -impl ResourceBuilder for Builder { +impl ResourceBuilder for Builder { const TYPE: Type = Type::Custom; - type Config = Self; - type Output = String; - fn new() -> Self { - Self { - name: String::new(), - } - } - fn config(&self) -> &Self::Config { self } - async fn output( - self, - _factory: &mut dyn Factory, - ) -> Result { + async fn output(self, _factory: &mut dyn Factory) -> Result { + // factory can be used to get resources from Shuttle Ok(self.name) } +} - async fn build(build_data: &Self::Output) -> Result { - Ok(Pdo { - name: build_data.clone(), - }) +#[async_trait] +impl IntoResource for String { + async fn into_resource(self) -> Result { + Ok(Pdo { name: self }) } } diff --git a/custom-service/none/Cargo.toml b/custom-service/none/Cargo.toml index a62cb2c4..4153900c 100644 --- a/custom-service/none/Cargo.toml +++ b/custom-service/none/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" publish = false [dependencies] -shuttle-runtime = "0.36.0" +shuttle-runtime = "0.37.0" tokio = "1" diff --git a/custom-service/request-scheduler/Cargo.toml b/custom-service/request-scheduler/Cargo.toml index 3df5ca96..1b06f081 100644 --- a/custom-service/request-scheduler/Cargo.toml +++ b/custom-service/request-scheduler/Cargo.toml @@ -10,7 +10,7 @@ chrono = "0.4.24" cron = "0.12.0" reqwest = "0.11.17" serde = "1.0.163" -shuttle-persist = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-persist = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.28.0" tracing = "0.1.37" diff --git a/fullstack-templates/saas/Cargo.toml b/fullstack-templates/saas/Cargo.toml index ac13fe2f..0147b768 100644 --- a/fullstack-templates/saas/Cargo.toml +++ b/fullstack-templates/saas/Cargo.toml @@ -1,2 +1,3 @@ [workspace] +resolver = "2" members = ["backend"] diff --git a/fullstack-templates/saas/backend/Cargo.toml b/fullstack-templates/saas/backend/Cargo.toml index 490cf9a9..85e8fd5d 100644 --- a/fullstack-templates/saas/backend/Cargo.toml +++ b/fullstack-templates/saas/backend/Cargo.toml @@ -16,11 +16,11 @@ lettre = "0.10.4" rand = "0.8.5" reqwest = "0.11.16" serde = { version = "1.0.160", features = ["derive"] } -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" -shuttle-secrets = "0.36.0" -shuttle-shared-db = { version = "0.36.0", features = ["postgres"] } -sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres", "time"] } +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" +shuttle-secrets = "0.37.0" +shuttle-shared-db = { version = "0.37.0", features = ["postgres", "sqlx"] } +sqlx = "0.7.1" time = { version = "0.3.20", features = ["serde"] } tokio = "1.27.0" tower = "0.4.13" diff --git a/next/hello-world/Cargo.toml b/next/hello-world/Cargo.toml index dd9587fd..a12c380a 100644 --- a/next/hello-world/Cargo.toml +++ b/next/hello-world/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" crate-type = [ "cdylib" ] [dependencies] -shuttle-next = "0.36.0" +shuttle-next = "0.37.0" tracing = "0.1.37" futures = "0.3.25" diff --git a/other/standalone-binary/Cargo.toml b/other/standalone-binary/Cargo.toml index c7107010..c081af8d 100644 --- a/other/standalone-binary/Cargo.toml +++ b/other/standalone-binary/Cargo.toml @@ -15,7 +15,7 @@ path = "src/bin/standalone.rs" [dependencies] axum = "0.7.3" dotenvy = "0.15.7" -shuttle-axum = "0.36.0" -shuttle-runtime = "0.36.0" -shuttle-secrets = "0.36.0" +shuttle-axum = "0.37.0" +shuttle-runtime = "0.37.0" +shuttle-secrets = "0.37.0" tokio = "1.28.2" diff --git a/poem/hello-world/Cargo.toml b/poem/hello-world/Cargo.toml index 85756ec7..8ae6a3c3 100644 --- a/poem/hello-world/Cargo.toml +++ b/poem/hello-world/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -poem = "1.3.55" -shuttle-poem = "0.36.0" -shuttle-runtime = "0.36.0" +poem = "2.0.0" +shuttle-poem = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" diff --git a/poem/mongodb/Cargo.toml b/poem/mongodb/Cargo.toml index 462f585f..e80a1d63 100644 --- a/poem/mongodb/Cargo.toml +++ b/poem/mongodb/Cargo.toml @@ -5,10 +5,10 @@ edition = "2021" [dependencies] mongodb = "2.4.0" -poem = "1.3.55" -shuttle-poem = "0.36.0" -shuttle-shared-db = { version = "0.36.0", features = ["mongodb"] } -shuttle-runtime = "0.36.0" +poem = "2.0.0" +shuttle-poem = "0.37.0" +shuttle-shared-db = { version = "0.37.0", features = ["mongodb"] } +shuttle-runtime = "0.37.0" serde = { version = "1.0.148", features = ["derive"] } serde_json = "1.0.89" tokio = "1.26.0" diff --git a/poem/postgres/Cargo.toml b/poem/postgres/Cargo.toml index 080da2b6..3183a76f 100644 --- a/poem/postgres/Cargo.toml +++ b/poem/postgres/Cargo.toml @@ -4,10 +4,10 @@ version = "0.1.0" edition = "2021" [dependencies] -poem = "1.3.55" +poem = "2.0.0" serde = "1.0.148" -shuttle-poem = "0.36.0" -shuttle-runtime = "0.36.0" -shuttle-shared-db = { version = "0.36.0", features = ["postgres"] } -sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] } +shuttle-poem = "0.37.0" +shuttle-runtime = "0.37.0" +shuttle-shared-db = { version = "0.37.0", features = ["postgres", "sqlx"] } +sqlx = "0.7.1" tokio = "1.26.0" diff --git a/poise/hello-world/Cargo.toml b/poise/hello-world/Cargo.toml index e7b54cc1..7a119b21 100644 --- a/poise/hello-world/Cargo.toml +++ b/poise/hello-world/Cargo.toml @@ -1,14 +1,15 @@ [package] -name = "hello-world" +name = "hello-world-poise-bot" version = "0.1.0" edition = "2021" publish = false [dependencies] anyhow = "1.0.68" -poise = "0.5.2" -shuttle-poise = "0.36.0" -shuttle-runtime = "0.36.0" -shuttle-secrets = "0.36.0" +poise = "0.6.1" +shuttle-runtime = "0.37.0" +shuttle-secrets = "0.37.0" +# Since poise is a serenity command framework, it can run on Shuttle with shuttle-serenity +shuttle-serenity = "0.37.0" tracing = "0.1.37" tokio = "1.26.0" diff --git a/poise/hello-world/Shuttle.toml b/poise/hello-world/Shuttle.toml deleted file mode 100644 index 4ebb812b..00000000 --- a/poise/hello-world/Shuttle.toml +++ /dev/null @@ -1 +0,0 @@ -name = "hello-world-poise-bot" diff --git a/poise/hello-world/src/main.rs b/poise/hello-world/src/main.rs index 1219db60..64abe991 100644 --- a/poise/hello-world/src/main.rs +++ b/poise/hello-world/src/main.rs @@ -1,7 +1,7 @@ use anyhow::Context as _; -use poise::serenity_prelude as serenity; -use shuttle_poise::ShuttlePoise; +use poise::serenity_prelude::{ClientBuilder, GatewayIntents}; use shuttle_secrets::SecretStore; +use shuttle_serenity::ShuttleSerenity; struct Data {} // User data, which is stored and accessible in all command invocations type Error = Box; @@ -15,7 +15,7 @@ async fn hello(ctx: Context<'_>) -> Result<(), Error> { } #[shuttle_runtime::main] -async fn poise(#[shuttle_secrets::Secrets] secret_store: SecretStore) -> ShuttlePoise { +async fn main(#[shuttle_secrets::Secrets] secret_store: SecretStore) -> ShuttleSerenity { // Get the discord token set in `Secrets.toml` let discord_token = secret_store .get("DISCORD_TOKEN") @@ -26,17 +26,18 @@ async fn poise(#[shuttle_secrets::Secrets] secret_store: SecretStore) -> Shuttle commands: vec![hello()], ..Default::default() }) - .token(discord_token) - .intents(serenity::GatewayIntents::non_privileged()) .setup(|ctx, _ready, framework| { Box::pin(async move { poise::builtins::register_globally(ctx, &framework.options().commands).await?; Ok(Data {}) }) }) - .build() + .build(); + + let client = ClientBuilder::new(discord_token, GatewayIntents::non_privileged()) + .framework(framework) .await .map_err(shuttle_runtime::CustomError::new)?; - Ok(framework.into()) + Ok(client.into()) } diff --git a/rocket/dyn-templates/Cargo.toml b/rocket/dyn-templates/Cargo.toml index ffb880f6..d9ca469d 100644 --- a/rocket/dyn-templates/Cargo.toml +++ b/rocket/dyn-templates/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] rocket = "0.5.0" -shuttle-rocket = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-rocket = "0.37.0" +shuttle-runtime = "0.37.0" rocket_dyn_templates = { version = "0.1.0-rc.4", features = ["handlebars"] } tokio = "1.26.0" diff --git a/rocket/hello-world/Cargo.toml b/rocket/hello-world/Cargo.toml index d334b4ab..ce7724ca 100644 --- a/rocket/hello-world/Cargo.toml +++ b/rocket/hello-world/Cargo.toml @@ -5,6 +5,6 @@ edition = "2021" [dependencies] rocket = "0.5.0" -shuttle-rocket = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-rocket = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" diff --git a/rocket/jwt-authentication/Cargo.toml b/rocket/jwt-authentication/Cargo.toml index d478c63a..1a48e25c 100644 --- a/rocket/jwt-authentication/Cargo.toml +++ b/rocket/jwt-authentication/Cargo.toml @@ -9,6 +9,6 @@ jsonwebtoken = { version = "8.1.1", default-features = false } lazy_static = "1.4.0" rocket = { version = "0.5.0", features = ["json"] } serde = { version = "1.0.148", features = ["derive"] } -shuttle-rocket = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-rocket = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" diff --git a/rocket/persist/Cargo.toml b/rocket/persist/Cargo.toml index b3757d59..af3127e7 100644 --- a/rocket/persist/Cargo.toml +++ b/rocket/persist/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] rocket = { version = "0.5.0", features = ["json"] } serde = { version = "1.0.148", features = ["derive"] } -shuttle-persist = "0.36.0" -shuttle-rocket = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-persist = "0.37.0" +shuttle-rocket = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" diff --git a/rocket/postgres/Cargo.toml b/rocket/postgres/Cargo.toml index e596717e..03f3e91a 100644 --- a/rocket/postgres/Cargo.toml +++ b/rocket/postgres/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" [dependencies] rocket = { version = "0.5.0", features = ["json"] } serde = "1.0.148" -shuttle-shared-db = { version = "0.36.0", features = ["postgres"] } -shuttle-rocket = "0.36.0" -shuttle-runtime = "0.36.0" -sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] } +shuttle-rocket = "0.37.0" +shuttle-runtime = "0.37.0" +shuttle-shared-db = { version = "0.37.0", features = ["postgres", "sqlx"] } +sqlx = "0.7.1" tokio = "1.26.0" diff --git a/rocket/secrets/Cargo.toml b/rocket/secrets/Cargo.toml index cf494bfb..0171e106 100644 --- a/rocket/secrets/Cargo.toml +++ b/rocket/secrets/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] anyhow = "1.0.66" rocket = "0.5.0" -shuttle-rocket = "0.36.0" -shuttle-runtime = "0.36.0" -shuttle-secrets = "0.36.0" +shuttle-rocket = "0.37.0" +shuttle-runtime = "0.37.0" +shuttle-secrets = "0.37.0" tokio = "1.26.0" diff --git a/rocket/static-files/Cargo.toml b/rocket/static-files/Cargo.toml index a3bd473a..55157c27 100644 --- a/rocket/static-files/Cargo.toml +++ b/rocket/static-files/Cargo.toml @@ -5,6 +5,6 @@ edition = "2021" [dependencies] rocket = "0.5.0" -shuttle-rocket = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-rocket = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" diff --git a/rocket/url-shortener/Cargo.toml b/rocket/url-shortener/Cargo.toml index 9b420c3d..f720259a 100644 --- a/rocket/url-shortener/Cargo.toml +++ b/rocket/url-shortener/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" [dependencies] nanoid = "0.4.0" rocket = { version = "0.5.0", features = ["json"] } -shuttle-rocket = "0.36.0" -shuttle-runtime = "0.36.0" serde = "1.0.148" -shuttle-shared-db = { version = "0.36.0", features = ["postgres"] } -sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] } +shuttle-rocket = "0.37.0" +shuttle-runtime = "0.37.0" +shuttle-shared-db = { version = "0.37.0", features = ["postgres", "sqlx"] } +sqlx = "0.7.1" tokio = "1.26.0" url = "2.3.1" diff --git a/rocket/workspace/hello-world/Cargo.toml b/rocket/workspace/hello-world/Cargo.toml index c07c33ff..07f462d4 100644 --- a/rocket/workspace/hello-world/Cargo.toml +++ b/rocket/workspace/hello-world/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" [dependencies] rocket = "0.5.0" shared = { path = "../shared", version = "0.1.0" } -shuttle-rocket = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-rocket = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" diff --git a/salvo/hello-world/Cargo.toml b/salvo/hello-world/Cargo.toml index a4eef6e2..7402a7f7 100644 --- a/salvo/hello-world/Cargo.toml +++ b/salvo/hello-world/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] salvo = "0.63.0" -shuttle-salvo = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-salvo = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" diff --git a/serenity/hello-world/Cargo.toml b/serenity/hello-world/Cargo.toml index 6878dd9f..e06204f3 100644 --- a/serenity/hello-world/Cargo.toml +++ b/serenity/hello-world/Cargo.toml @@ -1,13 +1,13 @@ [package] -name = "hello-world" +name = "hello-world-serenity-bot" version = "0.1.0" edition = "2021" [dependencies] anyhow = "1.0.66" -shuttle-serenity = "0.36.0" -shuttle-runtime = "0.36.0" -serenity = { version = "0.11.5", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] } -shuttle-secrets = "0.36.0" +serenity = { version = "0.12.0", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] } +shuttle-runtime = "0.37.0" +shuttle-secrets = "0.37.0" +shuttle-serenity = "0.37.0" tokio = "1.26.0" tracing = "0.1.37" diff --git a/serenity/hello-world/Shuttle.toml b/serenity/hello-world/Shuttle.toml deleted file mode 100644 index 39fe0983..00000000 --- a/serenity/hello-world/Shuttle.toml +++ /dev/null @@ -1 +0,0 @@ -name = "hello-world-serenity-bot" diff --git a/serenity/postgres/Cargo.toml b/serenity/postgres/Cargo.toml index 7826e730..d8ea5012 100644 --- a/serenity/postgres/Cargo.toml +++ b/serenity/postgres/Cargo.toml @@ -1,16 +1,16 @@ [package] -name = "serenity-postgres" +name = "postgres-serenity-bot" version = "0.1.0" edition = "2021" [dependencies] anyhow = "1.0.66" serde = "1.0.148" -serenity = { version = "0.11.5", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] } -shuttle-secrets = "0.36.0" -shuttle-serenity = "0.36.0" -shuttle-runtime = "0.36.0" -shuttle-shared-db = { version = "0.36.0", features = ["postgres"] } -sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] } +serenity = { version = "0.12.0", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] } +shuttle-runtime = "0.37.0" +shuttle-secrets = "0.37.0" +shuttle-serenity = "0.37.0" +shuttle-shared-db = { version = "0.37.0", features = ["postgres", "sqlx"] } +sqlx = "0.7.1" tokio = "1.26.0" tracing = "0.1.37" diff --git a/serenity/postgres/Shuttle.toml b/serenity/postgres/Shuttle.toml deleted file mode 100644 index bc686807..00000000 --- a/serenity/postgres/Shuttle.toml +++ /dev/null @@ -1 +0,0 @@ -name = "postgres-serenity-bot" diff --git a/serenity/postgres/src/main.rs b/serenity/postgres/src/main.rs index c878fb39..d908ebff 100644 --- a/serenity/postgres/src/main.rs +++ b/serenity/postgres/src/main.rs @@ -1,8 +1,9 @@ use anyhow::Context as _; use serenity::async_trait; -use serenity::model::application::command::CommandOptionType; -use serenity::model::application::interaction::application_command::CommandDataOptionValue; -use serenity::model::application::interaction::{Interaction, InteractionResponseType}; +use serenity::builder::{ + CreateCommand, CreateCommandOption, CreateInteractionResponse, CreateInteractionResponseMessage, +}; +use serenity::model::application::{CommandDataOptionValue, CommandOptionType, Interaction}; use serenity::model::gateway::Ready; use serenity::model::id::GuildId; use serenity::prelude::*; @@ -20,54 +21,52 @@ struct Bot { #[async_trait] impl EventHandler for Bot { async fn interaction_create(&self, ctx: Context, interaction: Interaction) { - let user_id: i64 = interaction - .clone() - .application_command() - .unwrap() - .user - .id - .into(); - - if let Interaction::ApplicationCommand(command) = interaction { + if let Interaction::Command(command) = interaction { info!("Received command interaction: {:#?}", command); + let user_id: i64 = command.user.id.into(); + let content = match command.data.name.as_str() { "todo" => { - let command = command.data.options.get(0).expect("Expected command"); + let command = command.data.options.first().expect("Expected command"); - // if the todo subcommand has a CommandOption the command is either `add` or `complete` - if let Some(subcommand) = command.options.get(0) { - match subcommand.resolved.as_ref().expect("Valid subcommand") { - CommandDataOptionValue::String(note) => { + match command.name.as_str() { + "add" => match &command.value { + CommandDataOptionValue::SubCommand(opts) => { + let note = opts.first().unwrap().value.as_str().unwrap(); db::add(&self.database, note, user_id).await.unwrap() } - CommandDataOptionValue::Integer(index) => { - db::complete(&self.database, index, user_id) + _ => "Command not implemented".to_string(), + }, + "complete" => match &command.value { + CommandDataOptionValue::SubCommand(opts) => { + let index = opts.first().unwrap().value.as_i64().unwrap(); + db::complete(&self.database, &index, user_id) .await .unwrap_or_else(|_| { "Please submit a valid index from your todo list" .to_string() }) } - _ => "Please enter a valid todo".to_string(), - } - // if the todo subcommand doesn't have a CommandOption the command is `list` - } else { - db::list(&self.database, user_id).await.unwrap() + _ => "Command not implemented".to_string(), + }, + "list" => db::list(&self.database, user_id).await.unwrap(), + _ => "Command not implemented".to_string(), } } _ => "Command not implemented".to_string(), }; if let Err(why) = command - .create_interaction_response(&ctx.http, |response| { - response - .kind(InteractionResponseType::ChannelMessageWithSource) - .interaction_response_data(|message| message.content(content)) - }) + .create_response( + &ctx.http, + CreateInteractionResponse::Message( + CreateInteractionResponseMessage::new().content(content), + ), + ) .await { - error!("Cannot respond to slash command: {}", why); + error!("Cannot respond to slash command: {why}"); } } } @@ -75,51 +74,53 @@ impl EventHandler for Bot { async fn ready(&self, ctx: Context, ready: Ready) { info!("{} is connected!", ready.user.name); - let guild_id = GuildId(self.guild_id.parse().unwrap()); + let guild_id = GuildId::new(self.guild_id.parse().unwrap()); - let _ = GuildId::set_application_commands(&guild_id, &ctx.http, |commands| { - commands.create_application_command(|command| { - command - .name("todo") + let _ = guild_id + .set_commands( + &ctx.http, + vec![CreateCommand::new("todo") .description("Add, list and complete todos") - .create_option(|option| { - option - .name("add") - .description("Add a new todo") - .kind(CommandOptionType::SubCommand) - .create_sub_option(|option| { - option - .name("note") - .description("The todo note to add") - .kind(CommandOptionType::String) - .min_length(2) - .max_length(100) - .required(true) - }) - }) - .create_option(|option| { - option - .name("complete") - .description("The todo to complete") - .kind(CommandOptionType::SubCommand) - .create_sub_option(|option| { - option - .name("index") - .description("The index of the todo to complete") - .kind(CommandOptionType::Integer) - .min_int_value(1) - .required(true) - }) - }) - .create_option(|option| { - option - .name("list") - .description("List your todos") - .kind(CommandOptionType::SubCommand) - }) - }) - }) - .await; + .add_option( + CreateCommandOption::new( + CommandOptionType::SubCommand, + "add", + "Add a new todo", + ) + .add_sub_option( + CreateCommandOption::new( + CommandOptionType::String, + "note", + "The todo note to add", + ) + .min_length(2) + .max_length(100) + .required(true), + ), + ) + .add_option( + CreateCommandOption::new( + CommandOptionType::SubCommand, + "complete", + "The todo to complete", + ) + .add_sub_option( + CreateCommandOption::new( + CommandOptionType::Integer, + "index", + "The index of the todo to complete", + ) + .min_int_value(1) + .required(true), + ), + ) + .add_option(CreateCommandOption::new( + CommandOptionType::SubCommand, + "list", + "List your todos", + ))], + ) + .await; } } diff --git a/thruster/hello-world/Cargo.toml b/thruster/hello-world/Cargo.toml index f7003cde..a98b921c 100644 --- a/thruster/hello-world/Cargo.toml +++ b/thruster/hello-world/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -shuttle-thruster = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-thruster = "0.37.0" +shuttle-runtime = "0.37.0" thruster = { version = "1.3.0", features = ["hyper_server"] } tokio = "1.26.0" diff --git a/thruster/postgres/Cargo.toml b/thruster/postgres/Cargo.toml index e10eae8c..0281d839 100644 --- a/thruster/postgres/Cargo.toml +++ b/thruster/postgres/Cargo.toml @@ -7,9 +7,9 @@ edition = "2021" hyper = "0.14.23" serde = { version = "1.0.148", features = ["derive"] } serde_json = "1.0.89" -shuttle-aws-rds = { version = "0.36.0", features = ["postgres"] } -shuttle-thruster = "0.36.0" -shuttle-runtime = "0.36.0" -sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] } +shuttle-aws-rds = { version = "0.37.0", features = ["postgres", "sqlx"] } +shuttle-runtime = "0.37.0" +shuttle-thruster = "0.37.0" +sqlx = "0.7.1" thruster = { version = "1.3.0", features = ["hyper_server"] } tokio = "1.26.0" diff --git a/tide/hello-world/Cargo.toml b/tide/hello-world/Cargo.toml index 7f3874ea..5f6f7308 100644 --- a/tide/hello-world/Cargo.toml +++ b/tide/hello-world/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -shuttle-tide = "0.36.0" -shuttle-runtime = "0.36.0" +shuttle-tide = "0.37.0" +shuttle-runtime = "0.37.0" tokio = "1.26.0" tide = "0.16.0" diff --git a/tide/postgres/Cargo.toml b/tide/postgres/Cargo.toml index 15e55ce9..d5c26450 100644 --- a/tide/postgres/Cargo.toml +++ b/tide/postgres/Cargo.toml @@ -5,9 +5,9 @@ edition = "2021" [dependencies] serde = { version = "1.0.148", features = ["derive"] } -shuttle-aws-rds = { version = "0.36.0", features = ["postgres"] } -shuttle-runtime = "0.36.0" -shuttle-tide = "0.36.0" -sqlx = { version = "0.7.1", features = ["runtime-tokio-native-tls", "postgres"] } +shuttle-aws-rds = { version = "0.37.0", features = ["postgres", "sqlx"] } +shuttle-runtime = "0.37.0" +shuttle-tide = "0.37.0" +sqlx = "0.7.1" tokio = "1.26.0" tide = "0.16.0" diff --git a/tower/hello-world/Cargo.toml b/tower/hello-world/Cargo.toml index 3edaa3cf..f58c44b8 100644 --- a/tower/hello-world/Cargo.toml +++ b/tower/hello-world/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] hyper = { version = "0.14.23", features = ["full"] } -shuttle-runtime = "0.36.0" -shuttle-tower = "0.36.0" +shuttle-runtime = "0.37.0" +shuttle-tower = "0.37.0" tower = { version = "0.4.13", features = ["full"] } tokio = "1.26.0" diff --git a/tracing/custom-tracing-subscriber/Cargo.toml b/tracing/custom-tracing-subscriber/Cargo.toml index b2519fb5..fb91b460 100644 --- a/tracing/custom-tracing-subscriber/Cargo.toml +++ b/tracing/custom-tracing-subscriber/Cargo.toml @@ -5,9 +5,9 @@ edition = "2021" [dependencies] actix-web = "4.3.1" -shuttle-actix-web = "0.36.0" +shuttle-actix-web = "0.37.0" # disable default features to disable the Shuttle default tracing subscriber -shuttle-runtime = { version = "0.36.0", default-features = false } +shuttle-runtime = { version = "0.37.0", default-features = false } tokio = "1.26.0" tracing = "0.1.37" tracing-subscriber = "0.3.17" diff --git a/warp/hello-world/Cargo.toml b/warp/hello-world/Cargo.toml index 23e08250..c14d91e7 100644 --- a/warp/hello-world/Cargo.toml +++ b/warp/hello-world/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -shuttle-runtime = "0.36.0" -shuttle-warp = "0.36.0" +shuttle-runtime = "0.37.0" +shuttle-warp = "0.37.0" tokio = "1.26.0" warp = "0.3.3"