From 11bdf28d679340a60bb0670578285c9834eb4d10 Mon Sep 17 00:00:00 2001 From: Jovi Hsu Date: Tue, 2 Nov 2021 00:58:24 +0800 Subject: [PATCH] Init backend --- .gitignore | 10 +--- Cargo.toml | 55 ++----------------- backend/Cargo.toml | 29 ++++++++++ backend/src/main.rs | 3 + frontend/.gitignore | 10 ++++ frontend/Cargo.toml | 51 +++++++++++++++++ {src => frontend/src}/app.rs | 0 {src => frontend/src}/lib.rs | 2 +- {src => frontend/src}/pages/mod.rs | 0 {src => frontend/src}/pages/page_home.rs | 0 {src => frontend/src}/pages/page_not_found.rs | 0 {src => frontend/src}/pages/page_ssh.rs | 0 {src => frontend/src}/utils.rs | 2 +- {www => frontend/www}/.gitignore | 0 {www => frontend/www}/bootstrap.js | 0 {www => frontend/www}/index.html | 0 {www => frontend/www}/index.js | 0 {www => frontend/www}/package-lock.json | 0 {www => frontend/www}/package.json | 0 {www => frontend/www}/webpack.config.js | 0 20 files changed, 101 insertions(+), 61 deletions(-) create mode 100644 backend/Cargo.toml create mode 100644 backend/src/main.rs create mode 100644 frontend/.gitignore create mode 100644 frontend/Cargo.toml rename {src => frontend/src}/app.rs (100%) rename {src => frontend/src}/lib.rs (100%) rename {src => frontend/src}/pages/mod.rs (100%) rename {src => frontend/src}/pages/page_home.rs (100%) rename {src => frontend/src}/pages/page_not_found.rs (100%) rename {src => frontend/src}/pages/page_ssh.rs (100%) rename {src => frontend/src}/utils.rs (99%) rename {www => frontend/www}/.gitignore (100%) rename {www => frontend/www}/bootstrap.js (100%) rename {www => frontend/www}/index.html (100%) rename {www => frontend/www}/index.js (100%) rename {www => frontend/www}/package-lock.json (100%) rename {www => frontend/www}/package.json (100%) rename {www => frontend/www}/webpack.config.js (100%) diff --git a/.gitignore b/.gitignore index 088ba6b..ed768f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,2 @@ -# Generated by Cargo -# will have compiled files and executables /target/ - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - -# These are backup files generated by rustfmt -**/*.rs.bk +Cargo.lock \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 3562c4c..9b7517e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,51 +1,6 @@ -[package] -authors = [ - "Jovi Hsu " -] -categories = ["wasm", "web-programming", "sslvpn"] -description = "" -edition = "2021" -keywords = ["yew", "wasm", "wasm-bindgen", "web", "sslvpn"] -license = "MIT" -name = "webgateway" -readme = "README.md" -version = "0.1.0" -repository = "https://www.github.com/HsuJv/webgateway" +[workspace] - -[lib] -crate-type = ["cdylib", "rlib"] - -[dependencies] -wasm-bindgen = "^0.2" -yew = "0.18" -js-sys = "0.3.55" -web-sys = "0.3.55" -yew-router = "0.15" -# The `console_error_panic_hook` crate provides better debugging of panics by -# logging them with `console.error`. This is great for development, but requires -# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for -# code size when deploying. -console_error_panic_hook = { version = "0.1.6", optional = true } -# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size -# compared to the default allocator's ~10K. It is slower than the default -# allocator, however. -wee_alloc = { version = "0.4", optional = true } - -[features] -default = ["console_error_panic_hook", "wee_alloc"] - -[dev-dependencies] -wasm-bindgen-test = "0.3.13" - -[profile.dev] -panic = "unwind" -opt-level = 0 - - - -[profile.release] -panic = 'abort' -codegen-units = 1 -opt-level = 's' -lto = true \ No newline at end of file +members = [ + "backend", + "frontend", +] \ No newline at end of file diff --git a/backend/Cargo.toml b/backend/Cargo.toml new file mode 100644 index 0000000..19689e8 --- /dev/null +++ b/backend/Cargo.toml @@ -0,0 +1,29 @@ +[package] +authors = [ + "Jovi Hsu " +] +categories = ["wasm", "web-programming", "sslvpn"] +description = "" +edition = "2021" +keywords = ["yew", "wasm", "wasm-bindgen", "web", "sslvpn"] +license = "GPL3" +name = "webgateway-be" +readme = "README.md" +version = "0.1.0" +repository = "https://www.github.com/HsuJv/webgateway" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[profile.dev] +panic = "unwind" +opt-level = 0 + + + +[profile.release] +panic = 'abort' +codegen-units = 1 +opt-level = 's' +lto = true \ No newline at end of file diff --git a/backend/src/main.rs b/backend/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/backend/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..088ba6b --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,10 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml new file mode 100644 index 0000000..794ecd1 --- /dev/null +++ b/frontend/Cargo.toml @@ -0,0 +1,51 @@ +[package] +authors = [ + "Jovi Hsu " +] +categories = ["wasm", "web-programming", "sslvpn"] +description = "" +edition = "2021" +keywords = ["yew", "wasm", "wasm-bindgen", "web", "sslvpn"] +license = "GPL3" +name = "webgateway-fe" +readme = "README.md" +version = "0.1.0" +repository = "https://www.github.com/HsuJv/webgateway" + + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +wasm-bindgen = "^0.2" +yew = "0.18" +js-sys = "0.3.55" +web-sys = "0.3.55" +yew-router = "0.15" +# The `console_error_panic_hook` crate provides better debugging of panics by +# logging them with `console.error`. This is great for development, but requires +# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for +# code size when deploying. +console_error_panic_hook = { version = "0.1.6", optional = true } +# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size +# compared to the default allocator's ~10K. It is slower than the default +# allocator, however. +wee_alloc = { version = "0.4", optional = true } + +[features] +default = ["console_error_panic_hook", "wee_alloc"] + +[dev-dependencies] +wasm-bindgen-test = "0.3.13" + +[profile.dev] +panic = "unwind" +opt-level = 0 + + + +[profile.release] +panic = 'abort' +codegen-units = 1 +opt-level = 's' +lto = true \ No newline at end of file diff --git a/src/app.rs b/frontend/src/app.rs similarity index 100% rename from src/app.rs rename to frontend/src/app.rs diff --git a/src/lib.rs b/frontend/src/lib.rs similarity index 100% rename from src/lib.rs rename to frontend/src/lib.rs index 0ed2799..0478693 100644 --- a/src/lib.rs +++ b/frontend/src/lib.rs @@ -1,6 +1,6 @@ mod app; -mod utils; mod pages; +mod utils; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; diff --git a/src/pages/mod.rs b/frontend/src/pages/mod.rs similarity index 100% rename from src/pages/mod.rs rename to frontend/src/pages/mod.rs diff --git a/src/pages/page_home.rs b/frontend/src/pages/page_home.rs similarity index 100% rename from src/pages/page_home.rs rename to frontend/src/pages/page_home.rs diff --git a/src/pages/page_not_found.rs b/frontend/src/pages/page_not_found.rs similarity index 100% rename from src/pages/page_not_found.rs rename to frontend/src/pages/page_not_found.rs diff --git a/src/pages/page_ssh.rs b/frontend/src/pages/page_ssh.rs similarity index 100% rename from src/pages/page_ssh.rs rename to frontend/src/pages/page_ssh.rs diff --git a/src/utils.rs b/frontend/src/utils.rs similarity index 99% rename from src/utils.rs rename to frontend/src/utils.rs index 8a790b9..c4be847 100644 --- a/src/utils.rs +++ b/frontend/src/utils.rs @@ -8,4 +8,4 @@ pub fn set_panic_hook() { // https://github.com/rustwasm/console_error_panic_hook#readme #[cfg(feature = "console_error_panic_hook")] console_error_panic_hook::set_once(); -} \ No newline at end of file +} diff --git a/www/.gitignore b/frontend/www/.gitignore similarity index 100% rename from www/.gitignore rename to frontend/www/.gitignore diff --git a/www/bootstrap.js b/frontend/www/bootstrap.js similarity index 100% rename from www/bootstrap.js rename to frontend/www/bootstrap.js diff --git a/www/index.html b/frontend/www/index.html similarity index 100% rename from www/index.html rename to frontend/www/index.html diff --git a/www/index.js b/frontend/www/index.js similarity index 100% rename from www/index.js rename to frontend/www/index.js diff --git a/www/package-lock.json b/frontend/www/package-lock.json similarity index 100% rename from www/package-lock.json rename to frontend/www/package-lock.json diff --git a/www/package.json b/frontend/www/package.json similarity index 100% rename from www/package.json rename to frontend/www/package.json diff --git a/www/webpack.config.js b/frontend/www/webpack.config.js similarity index 100% rename from www/webpack.config.js rename to frontend/www/webpack.config.js