From f3cf37bb0db8f64515378c658978366eff728e1d Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 17 Jul 2023 22:26:11 +0100 Subject: [PATCH] fix vue example ports closes #624 --- Cargo.lock | 23 ++-- cors/backend/Cargo.toml | 5 +- cors/backend/src/main.rs | 8 +- cors/frontend/src/app.vue | 219 +++++++++++++++++++++---------------- databases/mysql/Cargo.toml | 12 +- 5 files changed, 151 insertions(+), 116 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 19c3576..68dfe62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -491,17 +491,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "actix-web-cors" -version = "1.0.0" -dependencies = [ - "actix-cors", - "actix-web", - "env_logger", - "serde", - "serde_json", -] - [[package]] name = "actix-web-lab" version = "0.19.1" @@ -2296,6 +2285,18 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "cors" +version = "1.0.0" +dependencies = [ + "actix-cors", + "actix-web", + "env_logger", + "log", + "serde", + "serde_json", +] + [[package]] name = "cpufeatures" version = "0.2.9" diff --git a/cors/backend/Cargo.toml b/cors/backend/Cargo.toml index caf109b..f4a9349 100644 --- a/cors/backend/Cargo.toml +++ b/cors/backend/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "actix-web-cors" +name = "cors" version = "1.0.0" edition = "2021" @@ -8,5 +8,6 @@ actix-web = { workspace = true, features = ["rustls"] } actix-cors.workspace = true env_logger.workspace = true -serde = { version = "1.0", features = ["derive"] } +log.workspace = true +serde.workspace = true serde_json.workspace = true diff --git a/cors/backend/src/main.rs b/cors/backend/src/main.rs index d7664d3..55ab0df 100644 --- a/cors/backend/src/main.rs +++ b/cors/backend/src/main.rs @@ -1,17 +1,21 @@ +use std::io; + use actix_cors::Cors; use actix_web::{http::header, middleware::Logger, App, HttpServer}; mod user; #[actix_web::main] -async fn main() -> std::io::Result<()> { +async fn main() -> io::Result<()> { env_logger::init_from_env(env_logger::Env::default().default_filter_or("info")); + log::info!("starting HTTP server at http://localhost:8080"); + HttpServer::new(move || { App::new() .wrap( Cors::default() - .allowed_origin("http://localhost:8080") + .allowed_origin("http://localhost:8081") .allowed_methods(vec!["GET", "POST"]) .allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT]) .allowed_header(header::CONTENT_TYPE) diff --git a/cors/frontend/src/app.vue b/cors/frontend/src/app.vue index 3ba029d..171e352 100644 --- a/cors/frontend/src/app.vue +++ b/cors/frontend/src/app.vue @@ -1,22 +1,49 @@ @@ -24,48 +51,49 @@ @@ -76,26 +104,26 @@ export default { padding-top: 33px; } #title { - padding: 0.5rem 0; - font-size: 22px; - font-weight: bold; - background-color:bisque; - text-align: center; + padding: 0.5rem 0; + font-size: 22px; + font-weight: bold; + background-color: bisque; + text-align: center; } -input[type="text"], -input[type="password"] { +input[type='text'], +input[type='password'] { margin: 6px auto auto; width: 250px; height: 36px; border: none; - border-bottom: 1px solid #AAA; + border-bottom: 1px solid #aaa; font-size: 16px; } -#submit { +#submit { margin: 10px 0 20px 0; width: 250px; height: 33px; - background-color:bisque; + background-color: bisque; border: none; border-radius: 2px; font-family: 'Roboto', sans-serif; @@ -103,37 +131,38 @@ input[type="password"] { transition: 0.1s ease; cursor: pointer; } -input[type="checkbox"] { +input[type='checkbox'] { margin-top: 11px; } dialog { -top: 50%; -width: 80%; -border: 5px solid rgba(0, 0, 0, 0.3); + top: 50%; + width: 80%; + border: 5px solid rgba(0, 0, 0, 0.3); } -dialog::backdrop{ -position: fixed; -top: 0; -left: 0; -right: 0; -bottom: 0; -background-color: rgba(0, 0, 0, 0.7); +dialog::backdrop { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.7); } #closeDialog { -display: inline-block; -border-radius: 3px; -border: none; -font-size: 1rem; -padding: 0.4rem 0.8em; -background: #eb9816; -border-bottom: 1px solid #f1b75c; -color: white; -font-weight: bold; -text-align: center; + display: inline-block; + border-radius: 3px; + border: none; + font-size: 1rem; + padding: 0.4rem 0.8em; + background: #eb9816; + border-bottom: 1px solid #f1b75c; + color: white; + font-weight: bold; + text-align: center; } -#closeDialog:hover, #closeDialog:focus { -opacity: 0.92; -cursor: pointer; +#closeDialog:hover, +#closeDialog:focus { + opacity: 0.92; + cursor: pointer; } #user-info { width: 250px; @@ -141,9 +170,9 @@ cursor: pointer; padding-top: 44px; } @media only screen and (min-width: 600px) { - #content { - margin: 0 auto; - padding-top: 100px; + #content { + margin: 0 auto; + padding-top: 100px; } } diff --git a/databases/mysql/Cargo.toml b/databases/mysql/Cargo.toml index a05b633..dbf47c0 100644 --- a/databases/mysql/Cargo.toml +++ b/databases/mysql/Cargo.toml @@ -4,11 +4,11 @@ version = "1.0.0" edition = "2021" [dependencies] -actix-web = "4" -chrono = { version = "0.4.26", default-features = false, features = ["std", "clock"] } -derive_more = "0.99.7" +actix-web.workspace = true +chrono.workspace = true +derive_more.workspace = true dotenv = "0.15" -env_logger = "0.10" -log = "0.4" +env_logger.workspace = true +log.workspace = true mysql = "24" -serde = { version = "1", features = ["derive"] } +serde.workspace = true