From 1356d8cf482fef0b69429cf0eef9cfde73405752 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Fri, 15 Dec 2023 22:51:34 +0200 Subject: [PATCH 01/34] dependencies woo --- Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 11d38c9..23bd55b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,6 @@ edition = "2021" [dependencies] actix-web = "4" +serde = "1.0.193" +serde_json = "1.0.108" +sqlx = {version = "0.7.3", features=["postgres", "chrono", "uuid"]} From 3fbb68d3494d3eba2331a8b9fab82ca303814be7 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 21:51:05 +0200 Subject: [PATCH 02/34] dotenv thingy --- src/main.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0df93de..81208d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,5 @@ use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder}; - -#[get("/")] -async fn hello() -> impl Responder { - HttpResponse::Ok().body("Hello world!") -} +use dotenv::dotenv; #[post("/echo")] async fn echo(req_body: String) -> impl Responder { @@ -16,6 +12,7 @@ async fn manual_hello() -> impl Responder { #[actix_web::main] async fn main() -> std::io::Result<()> { + dotenv().ok(); HttpServer::new(|| { App::new() .service(hello) From 33074b4c6b4999d999662b8bec5c7b9b16d29ad8 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 22:12:59 +0200 Subject: [PATCH 03/34] db pool and address --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 81208d9..0177a44 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder}; use dotenv::dotenv; - +use witl_api::*; #[post("/echo")] async fn echo(req_body: String) -> impl Responder { HttpResponse::Ok().body(req_body) @@ -13,11 +13,12 @@ async fn manual_hello() -> impl Responder { #[actix_web::main] async fn main() -> std::io::Result<()> { dotenv().ok(); + let (port, address) = init_address(); HttpServer::new(|| { App::new() .service(hello) .service(echo) - .route("/hey", web::get().to(manual_hello)) + .app_data(web::Data::new(init_dbpool())) }) .bind(("localhost", 8080))? .run() From 7d0637d5dd64d31eb7784e4810a1927aa88d8225 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 23:25:57 +0200 Subject: [PATCH 04/34] awom arrivals module --- src/main.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0177a44..9b17a4a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,10 +5,7 @@ use witl_api::*; async fn echo(req_body: String) -> impl Responder { HttpResponse::Ok().body(req_body) } - -async fn manual_hello() -> impl Responder { - HttpResponse::Ok().body("Hey there!") -} +mod arrivals; #[actix_web::main] async fn main() -> std::io::Result<()> { From a7935b111e7b944f4c4fadfabe8f5bf37effe1b3 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 23:27:08 +0200 Subject: [PATCH 05/34] first scope added --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index 9b17a4a..a1f0fb5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,7 @@ async fn main() -> std::io::Result<()> { App::new() .service(hello) .service(echo) + .service(arrivals::init_arrivals_scope()) .app_data(web::Data::new(init_dbpool())) }) .bind(("localhost", 8080))? From 4f603f61d912d6548ab72e934e91ff873a7c3627 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 23:27:32 +0200 Subject: [PATCH 06/34] I hate that guy --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a1f0fb5..065c1ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,6 @@ async fn main() -> std::io::Result<()> { let (port, address) = init_address(); HttpServer::new(|| { App::new() - .service(hello) .service(echo) .service(arrivals::init_arrivals_scope()) .app_data(web::Data::new(init_dbpool())) From bbe15241d3bea101fd01e73b746ebcb2f71330c2 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 23:30:59 +0200 Subject: [PATCH 07/34] switch tuple order to satisfy trait --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 065c1ac..1b5f447 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ async fn main() -> std::io::Result<()> { .service(arrivals::init_arrivals_scope()) .app_data(web::Data::new(init_dbpool())) }) - .bind(("localhost", 8080))? + .bind(init_address())? .run() .await } From b5536659a612acebb1847af4101963833002cd30 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 23:32:02 +0200 Subject: [PATCH 08/34] arrivals module --- src/arrivals.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/arrivals.rs diff --git a/src/arrivals.rs b/src/arrivals.rs new file mode 100644 index 0000000..60870cf --- /dev/null +++ b/src/arrivals.rs @@ -0,0 +1,29 @@ +use actix_web::{get, web, HttpResponse, Responder}; + +pub fn init_arrivals_scope() -> actix_web::Scope { + let scope = web::scope("/arrivals").service(show_arrivals); + scope +} +use chrono::NaiveDateTime; +use serde::{Deserialize, Serialize}; +#[derive(Serialize, Deserialize)] +pub struct Arrival { + a_id: u32, + time_of_day: NaiveDateTime, + week_day: u32, + tram_line: u32, + direction: bool, +} +use web::Data; +use sqlx::{PgPool, query_as}; +#[get("arrivals")] +async fn show_arrivals(db_pool: Data) -> impl Responder { + let arrivals = query_as!(Arrival, r#"SELECT * FROM arrivals"#) + .fetch_all(db_pool) + .await + .expect("Could not fetch arrivals"); + HttpResponse::Ok() + .content_type("application/json") + .json(arrivals); + todo!() +} From caec9f609204050edc9fe5d3c11699bcf5ef7e40 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 23:33:40 +0200 Subject: [PATCH 09/34] lib.rs for functions outside main --- .gitignore | 1 + src/lib.rs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/lib.rs diff --git a/.gitignore b/.gitignore index ea8c4bf..fedaa2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +.env diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..81b3910 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,22 @@ +use std::env; + +pub fn init_address() -> (String, u16) { + let port: u16 = env::var("ACTIX_PORT") + .expect("SET ACTIX_PORT PLOX") + .parse() + .expect("Couldn't parse the ACTIX_PORT variable >:("); + let address = env::var("ACTIX_IP").expect("SET ACTIX_IP PLEASE"); + (address, port) +} +use sqlx::Pool; +pub async fn init_dbpool() -> Pool { + use sqlx::postgres::PgPoolOptions; + + let database_url = env::var("DATABASE_URL").expect("Put a DB url in the .env file dumbass"); + let pool = PgPoolOptions::new() + .max_connections(10) + .connect(database_url.as_str()) + .await + .expect("No pool connection man :("); + pool +} From fddbbe5577b9f8e0f8ad4429d53d4d8530717b50 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 23:33:59 +0200 Subject: [PATCH 10/34] cargo stuff --- Cargo.lock | 1045 +++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 2 + 2 files changed, 1035 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5bbabe..790cf79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -233,6 +233,46 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-write-file" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edcdbedc2236483ab103a53415653d6b4442ea6141baf1ffa85df29635e88436" +dependencies = [ + "nix", + "rand", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -260,6 +300,12 @@ version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bitflags" version = "1.3.2" @@ -271,6 +317,9 @@ name = "bitflags" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +dependencies = [ + "serde", +] [[package]] name = "block-buffer" @@ -302,6 +351,18 @@ dependencies = [ "alloc-stdlib", ] +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" version = "1.5.0" @@ -333,6 +394,27 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets 0.48.5", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "convert_case" version = "0.4.0" @@ -350,6 +432,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "cpufeatures" version = "0.2.11" @@ -359,6 +447,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.3.2" @@ -368,6 +471,25 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9bcf5bdbfdd6030fb4a1c497b5d5fc5921aa2f60d359a17e249c0e6df3de153" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" +dependencies = [ + "cfg-if", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -378,6 +500,17 @@ dependencies = [ "typenum", ] +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "deranged" version = "0.3.10" @@ -407,7 +540,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", + "subtle", +] + +[[package]] +name = "dotenv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +dependencies = [ + "serde", ] [[package]] @@ -425,6 +581,45 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "finl_unicode" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" + [[package]] name = "flate2" version = "1.0.28" @@ -435,6 +630,17 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "futures-core", + "futures-sink", + "spin 0.9.8", +] + [[package]] name = "fnv" version = "1.0.7" @@ -450,12 +656,50 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures-channel" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +dependencies = [ + "futures-core", + "futures-sink", +] + [[package]] name = "futures-core" version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +[[package]] +name = "futures-executor" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" + [[package]] name = "futures-sink" version = "0.3.29" @@ -475,9 +719,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-core", + "futures-io", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -531,6 +779,61 @@ name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "hashlink" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] [[package]] name = "http" @@ -555,6 +858,29 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "idna" version = "0.5.0" @@ -575,6 +901,15 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "itertools" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.9" @@ -590,18 +925,59 @@ dependencies = [ "libc", ] +[[package]] +name = "js-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "language-tags" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] + [[package]] name = "libc" version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "libsqlite3-sys" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" + [[package]] name = "local-channel" version = "0.1.5" @@ -635,6 +1011,16 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + [[package]] name = "memchr" version = "2.6.4" @@ -647,6 +1033,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -665,7 +1057,76 @@ dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.4.1", + "cfg-if", + "libc", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", + "libm", ] [[package]] @@ -703,7 +1164,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -712,6 +1173,15 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -730,6 +1200,27 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkg-config" version = "0.3.27" @@ -834,6 +1325,26 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "rsa" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -849,6 +1360,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "ryu" version = "1.0.15" @@ -921,6 +1445,17 @@ dependencies = [ "digest", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -930,6 +1465,16 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + [[package]] name = "slab" version = "0.4.9" @@ -952,9 +1497,264 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlformat" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce81b7bd7c4493975347ef60d8c7e8b742d4694f4c49f93e0a12ea263938176c" +dependencies = [ + "itertools", + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dba03c279da73694ef99763320dea58b51095dfe87d001b1d4b5fe78ba8763cf" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d84b0a3c3739e220d94b3239fd69fb1f74bc36e16643423bd99de3b43c21bfbd" +dependencies = [ + "ahash", + "atoi", + "byteorder", + "bytes", + "chrono", + "crc", + "crossbeam-queue", + "dotenvy", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap", + "log", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "thiserror", + "tracing", + "url", + "uuid", +] + +[[package]] +name = "sqlx-macros" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89961c00dc4d7dffb7aee214964b065072bff69e36ddb9e2c107541f75e4f2a5" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0bd4519486723648186a08785143599760f7cc81c52334a55d6a83ea1e20841" +dependencies = [ + "atomic-write-file", + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 1.0.109", + "tempfile", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e37195395df71fd068f6e2082247891bc11e3289624bbc776a0cdfa1ca7f1ea4" +dependencies = [ + "atoi", + "base64", + "bitflags 2.4.1", + "byteorder", + "bytes", + "chrono", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6ac0ac3b7ccd10cc96c7ab29791a7dd236bd94021f31eec7ba3d46a74aa1c24" +dependencies = [ + "atoi", + "base64", + "bitflags 2.4.1", + "byteorder", + "chrono", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand", + "serde", + "serde_json", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "210976b7d948c7ba9fced8ca835b11cbb2d677c59c79de41ac0d397e14547490" +dependencies = [ + "atoi", + "chrono", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "tracing", + "url", + "urlencoding", + "uuid", +] + +[[package]] +name = "stringprep" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb41d74e231a107a1b4ee36bd1214b11285b77768d2e3824aedafa988fd36ee6" +dependencies = [ + "finl_unicode", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + [[package]] name = "syn" version = "1.0.109" @@ -977,6 +1777,39 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tempfile" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall", + "rustix", + "windows-sys 0.48.0", +] + +[[package]] +name = "thiserror" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "time" version = "0.3.30" @@ -1035,7 +1868,7 @@ dependencies = [ "pin-project-lite", "signal-hook-registry", "socket2", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1060,9 +1893,21 @@ checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "tracing-core" version = "0.1.32" @@ -1099,6 +1944,18 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + [[package]] name = "url" version = "2.5.0" @@ -1110,6 +1967,24 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "uuid" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" @@ -1122,13 +1997,91 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" + +[[package]] +name = "whoami" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" + +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -1137,13 +2090,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -1152,47 +2120,94 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "witl-api" version = "0.1.0" dependencies = [ "actix-web", + "chrono", + "dotenv", + "serde", + "serde_json", + "sqlx", ] [[package]] @@ -1215,6 +2230,12 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + [[package]] name = "zstd" version = "0.12.4" diff --git a/Cargo.toml b/Cargo.toml index 23bd55b..c204d10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,8 @@ edition = "2021" [dependencies] actix-web = "4" +chrono = { version = "0.4.31", features = ["serde"] } +dotenv = "0.15.0" serde = "1.0.193" serde_json = "1.0.108" sqlx = {version = "0.7.3", features=["postgres", "chrono", "uuid"]} From 341bb51fdbd86c5e6821828001877cb3adaec539 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 23:34:44 +0200 Subject: [PATCH 11/34] async feature for sqlx --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c204d10..76e82bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,4 +11,4 @@ chrono = { version = "0.4.31", features = ["serde"] } dotenv = "0.15.0" serde = "1.0.193" serde_json = "1.0.108" -sqlx = {version = "0.7.3", features=["postgres", "chrono", "uuid"]} +sqlx = {version = "0.7.3", features=["postgres", "chrono", "uuid", "runtime-async-std"]} From 8edbc7e61d81f7e0b9c819f5dd66bf6f7ff43c06 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 23:57:26 +0200 Subject: [PATCH 12/34] no more warnings + debug --- src/arrivals.rs | 15 +++++++-------- src/main.rs | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index 60870cf..5fc29b3 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -4,14 +4,14 @@ pub fn init_arrivals_scope() -> actix_web::Scope { let scope = web::scope("/arrivals").service(show_arrivals); scope } -use chrono::NaiveDateTime; +use chrono::NaiveTime; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] pub struct Arrival { - a_id: u32, - time_of_day: NaiveDateTime, - week_day: u32, - tram_line: u32, + a_id: i32, + time_of_day: NaiveTime, + week_day: i32, + tram_line: i32, direction: bool, } use web::Data; @@ -19,11 +19,10 @@ use sqlx::{PgPool, query_as}; #[get("arrivals")] async fn show_arrivals(db_pool: Data) -> impl Responder { let arrivals = query_as!(Arrival, r#"SELECT * FROM arrivals"#) - .fetch_all(db_pool) + .fetch_all(db_pool.get_ref()) .await .expect("Could not fetch arrivals"); HttpResponse::Ok() .content_type("application/json") - .json(arrivals); - todo!() + .json(arrivals) } diff --git a/src/main.rs b/src/main.rs index 1b5f447..0866f03 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder}; +use actix_web::{post, web, App, HttpResponse, HttpServer, Responder}; use dotenv::dotenv; use witl_api::*; #[post("/echo")] @@ -10,7 +10,7 @@ mod arrivals; #[actix_web::main] async fn main() -> std::io::Result<()> { dotenv().ok(); - let (port, address) = init_address(); + std::env::set_var("RUST_LOG", "debug"); HttpServer::new(|| { App::new() .service(echo) From a09d19d442cd8a6a1accd160edf352b47a0f047c Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Sun, 17 Dec 2023 23:57:55 +0200 Subject: [PATCH 13/34] Ok --- src/arrivals.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index 5fc29b3..3937a1c 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -22,7 +22,7 @@ async fn show_arrivals(db_pool: Data) -> impl Responder { .fetch_all(db_pool.get_ref()) .await .expect("Could not fetch arrivals"); - HttpResponse::Ok() + HttpResponse::Ok() .content_type("application/json") .json(arrivals) } From f5c60e19d45078e288c2b4dcb5cfee049ad6daac Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Mon, 18 Dec 2023 00:07:00 +0200 Subject: [PATCH 14/34] DEBUG INIT --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index 0866f03..bb38de6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,7 @@ mod arrivals; async fn main() -> std::io::Result<()> { dotenv().ok(); std::env::set_var("RUST_LOG", "debug"); + env_logger::init(); HttpServer::new(|| { App::new() .service(echo) From 62f614acb804f40e5d078293368fae3c873c518c Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Mon, 18 Dec 2023 00:20:35 +0200 Subject: [PATCH 15/34] till I figure out how async actually works --- src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.rs b/src/main.rs index bb38de6..7610c58 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,12 @@ async fn main() -> std::io::Result<()> { dotenv().ok(); std::env::set_var("RUST_LOG", "debug"); env_logger::init(); + let database_url = env::var("DATABASE_URL").expect("Put a DB url in the .env file dumbass"); + let pool = sqlx::postgres::PgPoolOptions::new() + .max_connections(10) + .connect(database_url.as_str()) + .await + .expect("No pool connection man :("); HttpServer::new(|| { App::new() .service(echo) From 8152622ac8a16f88b70a5ac2b7932bd838d798f3 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Mon, 18 Dec 2023 00:20:55 +0200 Subject: [PATCH 16/34] I hit the code actions once --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7610c58..d50f3ca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use actix_web::{post, web, App, HttpResponse, HttpServer, Responder}; +use arrivals::init_arrivals_scope; use dotenv::dotenv; use witl_api::*; #[post("/echo")] @@ -21,8 +22,8 @@ async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .service(echo) - .service(arrivals::init_arrivals_scope()) - .app_data(web::Data::new(init_dbpool())) + .service(init_arrivals_scope()) + .app_data(web::Data::new(pool.clone())) }) .bind(init_address())? .run() From 2d6d20043a5ee9601d2f6f18586a5c7ab3c348f6 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Mon, 18 Dec 2023 00:21:41 +0200 Subject: [PATCH 17/34] std::env import --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index d50f3ca..c214e5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use std::env; use actix_web::{post, web, App, HttpResponse, HttpServer, Responder}; use arrivals::init_arrivals_scope; use dotenv::dotenv; From e153aae5edca54b035886b74d230f1a0702f880e Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Mon, 18 Dec 2023 00:22:03 +0200 Subject: [PATCH 18/34] debug added idky --- src/arrivals.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index 3937a1c..b4673bf 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -6,7 +6,7 @@ pub fn init_arrivals_scope() -> actix_web::Scope { } use chrono::NaiveTime; use serde::{Deserialize, Serialize}; -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] pub struct Arrival { a_id: i32, time_of_day: NaiveTime, @@ -16,12 +16,13 @@ pub struct Arrival { } use web::Data; use sqlx::{PgPool, query_as}; -#[get("arrivals")] +#[get("all")] async fn show_arrivals(db_pool: Data) -> impl Responder { let arrivals = query_as!(Arrival, r#"SELECT * FROM arrivals"#) .fetch_all(db_pool.get_ref()) .await .expect("Could not fetch arrivals"); + dbg!(&arrivals); HttpResponse::Ok() .content_type("application/json") .json(arrivals) From dc09921a5d1104c1f78be8561663ed4ff65ddad9 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Mon, 18 Dec 2023 00:24:02 +0200 Subject: [PATCH 19/34] cleaner code for init of db pool --- src/main.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index c214e5d..1339bea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,17 +14,12 @@ async fn main() -> std::io::Result<()> { dotenv().ok(); std::env::set_var("RUST_LOG", "debug"); env_logger::init(); - let database_url = env::var("DATABASE_URL").expect("Put a DB url in the .env file dumbass"); - let pool = sqlx::postgres::PgPoolOptions::new() - .max_connections(10) - .connect(database_url.as_str()) - .await - .expect("No pool connection man :("); - HttpServer::new(|| { + let db_pool = init_dbpool().await; + HttpServer::new(move || { App::new() .service(echo) - .service(init_arrivals_scope()) - .app_data(web::Data::new(pool.clone())) + .service(arrivals::init_arrivals_scope()) + .app_data(web::Data::new(db_pool.clone())) }) .bind(init_address())? .run() From 0dad808c75daff65afd29bce1ee07bf6a41e2879 Mon Sep 17 00:00:00 2001 From: LinlyBoi Date: Mon, 18 Dec 2023 00:27:48 +0200 Subject: [PATCH 20/34] lifting off --- Cargo.lock | 482 +++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 1 + src/main.rs | 2 - 3 files changed, 476 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 790cf79..7996e05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -103,7 +103,7 @@ dependencies = [ "futures-core", "futures-util", "mio", - "socket2", + "socket2 0.5.5", "tokio", "tracing", ] @@ -164,7 +164,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "smallvec", - "socket2", + "socket2 0.5.5", "time", "url", ] @@ -254,6 +254,150 @@ dependencies = [ "libc", ] +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener 2.5.3", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +dependencies = [ + "concurrent-queue", + "event-listener 4.0.0", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" +dependencies = [ + "async-lock 3.2.0", + "async-task", + "concurrent-queue", + "fastrand 2.0.1", + "futures-lite 2.1.0", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" +dependencies = [ + "async-channel 2.1.1", + "async-executor", + "async-io 2.2.2", + "async-lock 3.2.0", + "blocking", + "futures-lite 2.1.0", + "once_cell", +] + +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-lite 1.13.0", + "log", + "parking", + "polling 2.8.0", + "rustix 0.37.27", + "slab", + "socket2 0.4.10", + "waker-fn", +] + +[[package]] +name = "async-io" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6afaa937395a620e33dc6a742c593c01aced20aa376ffb0f628121198578ccc7" +dependencies = [ + "async-lock 3.2.0", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.1.0", + "parking", + "polling 3.3.1", + "rustix 0.38.28", + "slab", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +dependencies = [ + "event-listener 4.0.0", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-std" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +dependencies = [ + "async-channel 1.9.0", + "async-global-executor", + "async-io 1.13.0", + "async-lock 2.8.0", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite 1.13.0", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-task" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d90cd0b264dfdd8eb5bad0a2c217c1f88fa96a8573f40e7b12de23fb468f46" + [[package]] name = "atoi" version = "2.0.0" @@ -263,6 +407,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "atomic-write-file" version = "0.1.2" @@ -330,6 +480,22 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blocking" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +dependencies = [ + "async-channel 2.1.1", + "async-lock 3.2.0", + "async-task", + "fastrand 2.0.1", + "futures-io", + "futures-lite 2.1.0", + "piper", + "tracing", +] + [[package]] name = "brotli" version = "3.4.0" @@ -409,6 +575,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "concurrent-queue" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -575,6 +750,19 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "env_logger" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -608,6 +796,36 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.0", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + [[package]] name = "fastrand" version = "2.0.1" @@ -700,6 +918,34 @@ version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +[[package]] +name = "futures-lite" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-lite" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" +dependencies = [ + "fastrand 2.0.1", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + [[package]] name = "futures-sink" version = "0.3.29" @@ -755,6 +1001,18 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "h2" version = "0.3.22" @@ -802,6 +1060,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + [[package]] name = "hex" version = "0.4.3" @@ -858,6 +1122,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "iana-time-zone" version = "0.1.58" @@ -901,6 +1171,37 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi", + "rustix 0.38.28", + "windows-sys 0.48.0", +] + [[package]] name = "itertools" version = "0.12.0" @@ -934,6 +1235,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + [[package]] name = "language-tags" version = "0.3.2" @@ -972,6 +1282,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + [[package]] name = "linux-raw-sys" version = "0.4.12" @@ -1010,6 +1326,9 @@ name = "log" version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +dependencies = [ + "value-bag", +] [[package]] name = "md-5" @@ -1144,6 +1463,12 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" + [[package]] name = "parking_lot" version = "0.12.1" @@ -1200,6 +1525,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +dependencies = [ + "atomic-waker", + "fastrand 2.0.1", + "futures-io", +] + [[package]] name = "pkcs1" version = "0.7.5" @@ -1227,6 +1563,36 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "polling" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "concurrent-queue", + "libc", + "log", + "pin-project-lite", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" +dependencies = [ + "cfg-if", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.28", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -1360,6 +1726,20 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.37.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + [[package]] name = "rustix" version = "0.38.28" @@ -1369,7 +1749,7 @@ dependencies = [ "bitflags 2.4.1", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.4.12", "windows-sys 0.52.0", ] @@ -1490,6 +1870,16 @@ version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "socket2" version = "0.5.5" @@ -1556,6 +1946,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d84b0a3c3739e220d94b3239fd69fb1f74bc36e16643423bd99de3b43c21bfbd" dependencies = [ "ahash", + "async-io 1.13.0", + "async-std", "atoi", "byteorder", "bytes", @@ -1564,7 +1956,7 @@ dependencies = [ "crossbeam-queue", "dotenvy", "either", - "event-listener", + "event-listener 2.5.3", "futures-channel", "futures-core", "futures-intrusive", @@ -1608,6 +2000,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0bd4519486723648186a08785143599760f7cc81c52334a55d6a83ea1e20841" dependencies = [ + "async-std", "atomic-write-file", "dotenvy", "either", @@ -1784,12 +2177,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", - "fastrand", + "fastrand 2.0.1", "redox_syscall", - "rustix", + "rustix 0.38.28", "windows-sys 0.48.0", ] +[[package]] +name = "termcolor" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.50" @@ -1867,7 +2269,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2", + "socket2 0.5.5", "windows-sys 0.48.0", ] @@ -1979,6 +2381,12 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +[[package]] +name = "value-bag" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a72e1902dde2bd6441347de2b70b7f5d59bf157c6c62f0c44572607a1d55bbe" + [[package]] name = "vcpkg" version = "0.2.15" @@ -1991,6 +2399,12 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "waker-fn" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2022,6 +2436,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.89" @@ -2051,12 +2477,53 @@ version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +[[package]] +name = "web-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "whoami" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows-core" version = "0.51.1" @@ -2205,6 +2672,7 @@ dependencies = [ "actix-web", "chrono", "dotenv", + "env_logger", "serde", "serde_json", "sqlx", diff --git a/Cargo.toml b/Cargo.toml index 76e82bc..d9cee31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ edition = "2021" actix-web = "4" chrono = { version = "0.4.31", features = ["serde"] } dotenv = "0.15.0" +env_logger = "0.10.1" serde = "1.0.193" serde_json = "1.0.108" sqlx = {version = "0.7.3", features=["postgres", "chrono", "uuid", "runtime-async-std"]} diff --git a/src/main.rs b/src/main.rs index 1339bea..487c445 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,4 @@ -use std::env; use actix_web::{post, web, App, HttpResponse, HttpServer, Responder}; -use arrivals::init_arrivals_scope; use dotenv::dotenv; use witl_api::*; #[post("/echo")] From b011f3f972f76ae3176c1298ad1b65dc5077d058 Mon Sep 17 00:00:00 2001 From: Supermjork Date: Mon, 18 Dec 2023 18:18:52 +0200 Subject: [PATCH 21/34] FOUND DYNAMICALLY BUILDING SQLX QUERIES TOO LATE --- src/arrivals.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index b4673bf..d190584 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -15,7 +15,7 @@ pub struct Arrival { direction: bool, } use web::Data; -use sqlx::{PgPool, query_as}; +use sqlx::{PgPool, query_as, query}; #[get("all")] async fn show_arrivals(db_pool: Data) -> impl Responder { let arrivals = query_as!(Arrival, r#"SELECT * FROM arrivals"#) @@ -27,3 +27,25 @@ async fn show_arrivals(db_pool: Data) -> impl Responder { .content_type("application/json") .json(arrivals) } + +#[get("specific")] +async fn show_specific(db_pool: Data, type_arr: Vec) -> impl Responder { + // Query Logic + // Idea: Construct a query bit by bit depending on input + + let mut dyn_query = String::from("SELECT * FROM arrivals WHERE "); + + if type_arr.len() == 1 { + dyn_query.push_str(&format!("tram_line = {}", type_arr[0])); + } + + + // Check: https://stackoverflow.com/questions/74956100/how-to-build-safe-dynamic-query-with-sqlx-in-rust + // lappy ded ;-; + let arrivals = String::from("AIDS"); + + dbg!(&arrivals); + HttpResponse::Ok() + .content_type("application/json") + .json(arrivals) +} \ No newline at end of file From 739363855936b469077cd5f53a0d31ff2e3e6757 Mon Sep 17 00:00:00 2001 From: Supermjork Date: Mon, 18 Dec 2023 19:40:02 +0200 Subject: [PATCH 22/34] Schrodinger's SQL --- src/arrivals.rs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index d190584..8f0a570 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -14,6 +14,7 @@ pub struct Arrival { tram_line: i32, direction: bool, } + use web::Data; use sqlx::{PgPool, query_as, query}; #[get("all")] @@ -29,21 +30,34 @@ async fn show_arrivals(db_pool: Data) -> impl Responder { } #[get("specific")] -async fn show_specific(db_pool: Data, type_arr: Vec) -> impl Responder { +async fn show_specific(db_pool: Data, t_line: Vec, week_day: Some(u8)) -> impl Responder { // Query Logic // Idea: Construct a query bit by bit depending on input - let mut dyn_query = String::from("SELECT * FROM arrivals WHERE "); + let mut dyn_query = QueryBuilder::new("SELECT * FROM arrivals WHERE tram_line = "); - if type_arr.len() == 1 { - dyn_query.push_str(&format!("tram_line = {}", type_arr[0])); + if t_line.len() == 1 { + dyn_query.push_bind(t_line[0]); + } else { + dyn_query.push_bind(t_line[0]); + dyn_query.push("OR tram_line = "); + dyn_query.push_bind(t_line[1]); + } // Should be fine for tramline? + + if let Some(week_day) { + dyn_query.push("AND week_day = "); + dyn_query.push_bind(week_day); } + dyn_query.build().sql().into(); - // Check: https://stackoverflow.com/questions/74956100/how-to-build-safe-dynamic-query-with-sqlx-in-rust - // lappy ded ;-; + // We don't talk about this + // and idk if `query_as!()` will take a QueryBuilder let arrivals = String::from("AIDS"); + // Idk what to do, can't test with db cuz no .env xdxd + // linly pls i never made an api before and royal son doesn't count + dbg!(&arrivals); HttpResponse::Ok() .content_type("application/json") From a6235572e25b54c5c05d92f9b78407fa4c230273 Mon Sep 17 00:00:00 2001 From: Supermjork Date: Tue, 19 Dec 2023 11:21:44 +0200 Subject: [PATCH 23/34] Linby fix what i couldn't start plez xd --- src/arrivals.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index 8f0a570..9867a47 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -16,7 +16,7 @@ pub struct Arrival { } use web::Data; -use sqlx::{PgPool, query_as, query}; +use sqlx::{PgPool, query_as, QueryBuilder, Execute}; #[get("all")] async fn show_arrivals(db_pool: Data) -> impl Responder { let arrivals = query_as!(Arrival, r#"SELECT * FROM arrivals"#) @@ -30,12 +30,14 @@ async fn show_arrivals(db_pool: Data) -> impl Responder { } #[get("specific")] -async fn show_specific(db_pool: Data, t_line: Vec, week_day: Some(u8)) -> impl Responder { +async fn show_specific(db_pool: Data, t_line: Data>, week_day: Data) -> impl Responder { // Query Logic // Idea: Construct a query bit by bit depending on input + // GUESS NOT let mut dyn_query = QueryBuilder::new("SELECT * FROM arrivals WHERE tram_line = "); + // Delet cuz we hardcoding if t_line.len() == 1 { dyn_query.push_bind(t_line[0]); } else { @@ -44,10 +46,10 @@ async fn show_specific(db_pool: Data, t_line: Vec, week_day: Some(u8 dyn_query.push_bind(t_line[1]); } // Should be fine for tramline? - if let Some(week_day) { - dyn_query.push("AND week_day = "); - dyn_query.push_bind(week_day); - } + // Murder this (And me possibly) + dyn_query.push("AND week_day = "); + // Yes ik it's giving an encoding error, no i dont know how to fix, just nuke it + dyn_query.push_bind(week_day); dyn_query.build().sql().into(); From 8be818bcbd3defaa5a29bbb587f3f1c134680de6 Mon Sep 17 00:00:00 2001 From: linlyboi Date: Tue, 19 Dec 2023 12:09:01 +0200 Subject: [PATCH 24/34] Alright mark just message me to send an env file --- src/arrivals.rs | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index 9867a47..cb5f94b 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -30,38 +30,35 @@ async fn show_arrivals(db_pool: Data) -> impl Responder { } #[get("specific")] -async fn show_specific(db_pool: Data, t_line: Data>, week_day: Data) -> impl Responder { +async fn show_specific(db_pool: Data, t_line: Data, week_day: Data) -> impl Responder { // Query Logic // Idea: Construct a query bit by bit depending on input // GUESS NOT - let mut dyn_query = QueryBuilder::new("SELECT * FROM arrivals WHERE tram_line = "); + // Extract data and match nullables + let tram_line: i32 = match t_line.into() { + Some(num) => **num, + None => 1 as i32 - // Delet cuz we hardcoding - if t_line.len() == 1 { - dyn_query.push_bind(t_line[0]); - } else { - dyn_query.push_bind(t_line[0]); - dyn_query.push("OR tram_line = "); - dyn_query.push_bind(t_line[1]); - } // Should be fine for tramline? - - // Murder this (And me possibly) - dyn_query.push("AND week_day = "); - // Yes ik it's giving an encoding error, no i dont know how to fix, just nuke it - dyn_query.push_bind(week_day); - - dyn_query.build().sql().into(); + }; + let day = match week_day.into() { + Some(num) => **num, + None => 1 as i32, + }; + //Le query + let arrivals = query_as!(Arrival, "SELECT * FROM arrivals WHERE tram_line = $1 AND week_day = $2", tram_line, day) + .fetch_all(db_pool.get_ref()) + .await + .expect("Could not fetch arrivals"); // We don't talk about this // and idk if `query_as!()` will take a QueryBuilder let arrivals = String::from("AIDS"); - // Idk what to do, can't test with db cuz no .env xdxd - // linly pls i never made an api before and royal son doesn't count + // Delet cuz we hardcoding - dbg!(&arrivals); + // dbg!(&arrivals); HttpResponse::Ok() .content_type("application/json") .json(arrivals) -} \ No newline at end of file +} From ae693fc33f7df3b9f65448a6f077faadc7785d9a Mon Sep 17 00:00:00 2001 From: linlyboi Date: Tue, 19 Dec 2023 12:10:51 +0200 Subject: [PATCH 25/34] Fuck your comments --- src/arrivals.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index cb5f94b..5b35c28 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -31,9 +31,6 @@ async fn show_arrivals(db_pool: Data) -> impl Responder { #[get("specific")] async fn show_specific(db_pool: Data, t_line: Data, week_day: Data) -> impl Responder { - // Query Logic - // Idea: Construct a query bit by bit depending on input - // GUESS NOT // Extract data and match nullables let tram_line: i32 = match t_line.into() { @@ -51,9 +48,6 @@ async fn show_specific(db_pool: Data, t_line: Data, week_day: Data< .await .expect("Could not fetch arrivals"); - // We don't talk about this - // and idk if `query_as!()` will take a QueryBuilder - let arrivals = String::from("AIDS"); // Delet cuz we hardcoding From f21bb72007c868e3e8b8746b9a207664e1796562 Mon Sep 17 00:00:00 2001 From: linlyboi Date: Tue, 19 Dec 2023 12:16:49 +0200 Subject: [PATCH 26/34] no type annotations --- src/arrivals.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index 5b35c28..f80d47d 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -35,12 +35,12 @@ async fn show_specific(db_pool: Data, t_line: Data, week_day: Data< // Extract data and match nullables let tram_line: i32 = match t_line.into() { Some(num) => **num, - None => 1 as i32 + None => 1 }; let day = match week_day.into() { Some(num) => **num, - None => 1 as i32, + None => 1, }; //Le query let arrivals = query_as!(Arrival, "SELECT * FROM arrivals WHERE tram_line = $1 AND week_day = $2", tram_line, day) From 53c79295fe642cefa7e5baca26dea1ee7e822540 Mon Sep 17 00:00:00 2001 From: linlyboi Date: Tue, 19 Dec 2023 12:23:08 +0200 Subject: [PATCH 27/34] new struct pog --- src/arrivals.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arrivals.rs b/src/arrivals.rs index f80d47d..6d23fb4 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -28,6 +28,10 @@ async fn show_arrivals(db_pool: Data) -> impl Responder { .content_type("application/json") .json(arrivals) } +struct ArrivalFilter { + tram_line: i32, + week_day: i32, +} #[get("specific")] async fn show_specific(db_pool: Data, t_line: Data, week_day: Data) -> impl Responder { From 136b8ea2aa805997ff3b26617c83f7376152bd7f Mon Sep 17 00:00:00 2001 From: linlyboi Date: Tue, 19 Dec 2023 12:26:32 +0200 Subject: [PATCH 28/34] CLEANER CODE --- src/arrivals.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index 6d23fb4..fe8285e 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -28,26 +28,17 @@ async fn show_arrivals(db_pool: Data) -> impl Responder { .content_type("application/json") .json(arrivals) } +#[derive(Deserialize)] struct ArrivalFilter { tram_line: i32, week_day: i32, } #[get("specific")] -async fn show_specific(db_pool: Data, t_line: Data, week_day: Data) -> impl Responder { +async fn show_specific(db_pool: Data, filter: web::Query ) -> impl Responder { - // Extract data and match nullables - let tram_line: i32 = match t_line.into() { - Some(num) => **num, - None => 1 - - }; - let day = match week_day.into() { - Some(num) => **num, - None => 1, - }; //Le query - let arrivals = query_as!(Arrival, "SELECT * FROM arrivals WHERE tram_line = $1 AND week_day = $2", tram_line, day) + let arrivals = query_as!(Arrival, "SELECT * FROM arrivals WHERE tram_line = $1 AND week_day = $2", filter.tram_line, filter.week_day) .fetch_all(db_pool.get_ref()) .await .expect("Could not fetch arrivals"); From 1a49b551b3f77cd70cbae1b8df5eabfa686afe2f Mon Sep 17 00:00:00 2001 From: linlyboi Date: Tue, 19 Dec 2023 12:30:47 +0200 Subject: [PATCH 29/34] FORMAT --- src/arrivals.rs | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index fe8285e..c5d43ab 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -1,7 +1,9 @@ use actix_web::{get, web, HttpResponse, Responder}; pub fn init_arrivals_scope() -> actix_web::Scope { - let scope = web::scope("/arrivals").service(show_arrivals); + let scope = web::scope("/arrivals") + .service(show_arrivals) + .service(show_specific); scope } use chrono::NaiveTime; @@ -15,16 +17,16 @@ pub struct Arrival { direction: bool, } +use sqlx::{query_as, Execute, PgPool, QueryBuilder}; use web::Data; -use sqlx::{PgPool, query_as, QueryBuilder, Execute}; #[get("all")] async fn show_arrivals(db_pool: Data) -> impl Responder { let arrivals = query_as!(Arrival, r#"SELECT * FROM arrivals"#) .fetch_all(db_pool.get_ref()) .await .expect("Could not fetch arrivals"); - dbg!(&arrivals); - HttpResponse::Ok() + dbg!(&arrivals); + HttpResponse::Ok() .content_type("application/json") .json(arrivals) } @@ -35,19 +37,22 @@ struct ArrivalFilter { } #[get("specific")] -async fn show_specific(db_pool: Data, filter: web::Query ) -> impl Responder { - +async fn show_specific(db_pool: Data, filter: web::Query) -> impl Responder { //Le query - let arrivals = query_as!(Arrival, "SELECT * FROM arrivals WHERE tram_line = $1 AND week_day = $2", filter.tram_line, filter.week_day) - .fetch_all(db_pool.get_ref()) - .await - .expect("Could not fetch arrivals"); - + let arrivals = query_as!( + Arrival, + "SELECT * FROM arrivals WHERE tram_line = $1 AND week_day = $2", + filter.tram_line, + filter.week_day + ) + .fetch_all(db_pool.get_ref()) + .await + .expect("Could not fetch arrivals"); // Delet cuz we hardcoding - // dbg!(&arrivals); - HttpResponse::Ok() + // dbg!(&arrivals); + HttpResponse::Ok() .content_type("application/json") .json(arrivals) } From a19f79034b55fdea839186edff72bce83c93e13d Mon Sep 17 00:00:00 2001 From: linlyboi Date: Tue, 19 Dec 2023 12:33:53 +0200 Subject: [PATCH 30/34] cargo check moments --- src/arrivals.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index c5d43ab..1f3231e 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -17,7 +17,7 @@ pub struct Arrival { direction: bool, } -use sqlx::{query_as, Execute, PgPool, QueryBuilder}; +use sqlx::PgPool; use web::Data; #[get("all")] async fn show_arrivals(db_pool: Data) -> impl Responder { From c396c778add73cb8289f6db3f80769c139f2b25b Mon Sep 17 00:00:00 2001 From: linlyboi Date: Tue, 19 Dec 2023 12:34:23 +0200 Subject: [PATCH 31/34] one ting was missing --- src/arrivals.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index 1f3231e..3a3f56e 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -17,7 +17,7 @@ pub struct Arrival { direction: bool, } -use sqlx::PgPool; +use sqlx::{PgPool, query_as}; use web::Data; #[get("all")] async fn show_arrivals(db_pool: Data) -> impl Responder { From 45136a8e10846666999201abc64ec3714329acbf Mon Sep 17 00:00:00 2001 From: linlyboi Date: Tue, 19 Dec 2023 13:22:08 +0200 Subject: [PATCH 32/34] PLAY --- src/arrivals.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/arrivals.rs b/src/arrivals.rs index 3a3f56e..f5cd926 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -56,3 +56,14 @@ async fn show_specific(db_pool: Data, filter: web::Query) .content_type("application/json") .json(arrivals) } +#[post("new")] +async fn insert_arrival(db_pool: Data, arrival: web::Query) -> impl Responder { + query!( + "INSERT INTO arrivals (time_of_day,week_day,tram_line,direction) VALUES ($1, $2, $3, $4)", + arrival.time_of_day, + arrival.week_day, + arrival.tram_line, + arrival.direction + ).execute(db_pool.get_ref()).await.expect("I shat"); + HttpResponse::Ok().body("inserted") +} From 061ff570a68045ca74bb3a2106429a48c0173cdc Mon Sep 17 00:00:00 2001 From: linlyboi Date: Tue, 19 Dec 2023 13:22:14 +0200 Subject: [PATCH 33/34] Post added, new service, commented out id --- src/arrivals.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/arrivals.rs b/src/arrivals.rs index f5cd926..1dc10ea 100644 --- a/src/arrivals.rs +++ b/src/arrivals.rs @@ -1,30 +1,34 @@ -use actix_web::{get, web, HttpResponse, Responder}; +use actix_web::{get, web, HttpResponse, Responder, post}; pub fn init_arrivals_scope() -> actix_web::Scope { let scope = web::scope("/arrivals") .service(show_arrivals) - .service(show_specific); + .service(show_specific) + .service(insert_arrival); scope } use chrono::NaiveTime; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub struct Arrival { - a_id: i32, + // a_id: i32, time_of_day: NaiveTime, week_day: i32, tram_line: i32, direction: bool, } -use sqlx::{PgPool, query_as}; +use sqlx::{query, query_as, PgPool}; use web::Data; #[get("all")] async fn show_arrivals(db_pool: Data) -> impl Responder { - let arrivals = query_as!(Arrival, r#"SELECT * FROM arrivals"#) - .fetch_all(db_pool.get_ref()) - .await - .expect("Could not fetch arrivals"); + let arrivals = query_as!( + Arrival, + r#"SELECT time_of_day,week_day,tram_line,direction FROM arrivals"# + ) + .fetch_all(db_pool.get_ref()) + .await + .expect("Could not fetch arrivals"); dbg!(&arrivals); HttpResponse::Ok() .content_type("application/json") @@ -41,7 +45,7 @@ async fn show_specific(db_pool: Data, filter: web::Query) //Le query let arrivals = query_as!( Arrival, - "SELECT * FROM arrivals WHERE tram_line = $1 AND week_day = $2", + "SELECT time_of_day,week_day,tram_line,direction FROM arrivals WHERE tram_line = $1 AND week_day = $2", filter.tram_line, filter.week_day ) From ce117cae12cadad3f32ee877a240470b85c200a5 Mon Sep 17 00:00:00 2001 From: linlyboi Date: Tue, 19 Dec 2023 15:22:55 +0200 Subject: [PATCH 34/34] dotenv was abadonend lol --- Cargo.toml | 2 +- src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d9cee31..3e4dbb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] actix-web = "4" chrono = { version = "0.4.31", features = ["serde"] } -dotenv = "0.15.0" +dotenvy = "0.15.7" env_logger = "0.10.1" serde = "1.0.193" serde_json = "1.0.108" diff --git a/src/main.rs b/src/main.rs index 487c445..008413a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use actix_web::{post, web, App, HttpResponse, HttpServer, Responder}; -use dotenv::dotenv; +use dotenvy::dotenv; use witl_api::*; #[post("/echo")] async fn echo(req_body: String) -> impl Responder {