From 7e430e3000b84848ffda8ddec605c7782c3f87b2 Mon Sep 17 00:00:00 2001 From: Thilo Behnke Date: Sat, 11 Jun 2022 18:26:33 +0200 Subject: [PATCH] project structure cleanup --- Cargo.toml | 43 +----------------- .appveyor.yml => client/.appveyor.yml | 0 .travis.yml => client/.travis.yml | 0 client/Cargo.toml | 44 ++++++++++++++++++ LICENSE_APACHE => client/LICENSE_APACHE | 0 LICENSE_MIT => client/LICENSE_MIT | 0 README.md => client/README.md | 0 {nginx => client/nginx}/Dockerfile | 0 client/nginx/default.conf | 28 ++++++++++++ client/nginx/nginx.conf | 45 +++++++++++++++++++ {src => client/src}/lib.rs | 0 {src => client/src}/utils.rs | 0 {tests => client/tests}/web.rs | 0 {www => client/www}/.bin/create-wasm-app.js | 0 {www => client/www}/.gitignore | 0 {www => client/www}/.travis.yml | 0 {www => client/www}/LICENSE-APACHE | 0 {www => client/www}/LICENSE-MIT | 0 {www => client/www}/README.md | 0 {www => client/www}/bootstrap.js | 0 {www => client/www}/index.html | 0 {www => client/www}/index.js | 0 {www => client/www}/package-lock.json | 0 {www => client/www}/package.json | 0 {www => client/www}/webpack.config.js | 0 {server/kafka => kafka}/Dockerfile | 0 {server/kafka => kafka}/custom-entrypoint.sh | 0 .../kafka-script-proxy/.dockerignore | 0 .../kafka-script-proxy/.gitignore | 0 .../kafka-script-proxy/Cargo.toml | 0 .../kafka-script-proxy/src/main.rs | 0 src/main.rs | 0 32 files changed, 119 insertions(+), 41 deletions(-) rename .appveyor.yml => client/.appveyor.yml (100%) rename .travis.yml => client/.travis.yml (100%) create mode 100644 client/Cargo.toml rename LICENSE_APACHE => client/LICENSE_APACHE (100%) rename LICENSE_MIT => client/LICENSE_MIT (100%) rename README.md => client/README.md (100%) rename {nginx => client/nginx}/Dockerfile (100%) create mode 100644 client/nginx/default.conf create mode 100644 client/nginx/nginx.conf rename {src => client/src}/lib.rs (100%) rename {src => client/src}/utils.rs (100%) rename {tests => client/tests}/web.rs (100%) rename {www => client/www}/.bin/create-wasm-app.js (100%) rename {www => client/www}/.gitignore (100%) rename {www => client/www}/.travis.yml (100%) rename {www => client/www}/LICENSE-APACHE (100%) rename {www => client/www}/LICENSE-MIT (100%) rename {www => client/www}/README.md (100%) rename {www => client/www}/bootstrap.js (100%) rename {www => client/www}/index.html (100%) rename {www => client/www}/index.js (100%) rename {www => client/www}/package-lock.json (100%) rename {www => client/www}/package.json (100%) rename {www => client/www}/webpack.config.js (100%) rename {server/kafka => kafka}/Dockerfile (100%) rename {server/kafka => kafka}/custom-entrypoint.sh (100%) rename {server/kafka => kafka}/kafka-script-proxy/.dockerignore (100%) rename {server/kafka => kafka}/kafka-script-proxy/.gitignore (100%) rename {server/kafka => kafka}/kafka-script-proxy/Cargo.toml (100%) rename {server/kafka => kafka}/kafka-script-proxy/src/main.rs (100%) create mode 100644 src/main.rs diff --git a/Cargo.toml b/Cargo.toml index 7217af9..6fbcf87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,47 +1,8 @@ [package] -name = "rust-wasm" +name = "rust-wasm-pong" version = "0.1.0" authors = ["Thilo Behnke "] edition = "2018" [workspace] -members = ["pong", "server"] - -[lib] -crate-type = ["cdylib", "rlib"] - -[dependencies.web-sys] -version = "0.3" -features = [ - "console", -] - -[features] -default = ["console_error_panic_hook"] - -[dependencies] -wasm-bindgen = {version = "0.2.63", features = ["serde-serialize"]} -serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0.79" } -pong = { path = "pong", version = "0.1.0" } - -# 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. -# -# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now. -wee_alloc = { version = "0.4.5", optional = true } - -[dev-dependencies] -wasm-bindgen-test = "0.3.13" -rstest = "0.12.0" - -[profile.release] -# Tell `rustc` to optimize for small code size. -opt-level = "s" +members = ["client", "pong", "server"] diff --git a/.appveyor.yml b/client/.appveyor.yml similarity index 100% rename from .appveyor.yml rename to client/.appveyor.yml diff --git a/.travis.yml b/client/.travis.yml similarity index 100% rename from .travis.yml rename to client/.travis.yml diff --git a/client/Cargo.toml b/client/Cargo.toml new file mode 100644 index 0000000..78206c3 --- /dev/null +++ b/client/Cargo.toml @@ -0,0 +1,44 @@ +[package] +name = "rust-wasm" +version = "0.1.0" +authors = ["Thilo Behnke "] +edition = "2018" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies.web-sys] +version = "0.3" +features = [ + "console", +] + +[features] +default = ["console_error_panic_hook"] + +[dependencies] +wasm-bindgen = {version = "0.2.63", features = ["serde-serialize"]} +serde = { version = "1.0", features = ["derive"] } +serde_json = { version = "1.0.79" } +pong = { path = "../pong", version = "0.1.0" } + +# 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. +# +# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now. +wee_alloc = { version = "0.4.5", optional = true } + +[dev-dependencies] +wasm-bindgen-test = "0.3.13" +rstest = "0.12.0" + +[profile.release] +# Tell `rustc` to optimize for small code size. +opt-level = "s" diff --git a/LICENSE_APACHE b/client/LICENSE_APACHE similarity index 100% rename from LICENSE_APACHE rename to client/LICENSE_APACHE diff --git a/LICENSE_MIT b/client/LICENSE_MIT similarity index 100% rename from LICENSE_MIT rename to client/LICENSE_MIT diff --git a/README.md b/client/README.md similarity index 100% rename from README.md rename to client/README.md diff --git a/nginx/Dockerfile b/client/nginx/Dockerfile similarity index 100% rename from nginx/Dockerfile rename to client/nginx/Dockerfile diff --git a/client/nginx/default.conf b/client/nginx/default.conf new file mode 100644 index 0000000..1070949 --- /dev/null +++ b/client/nginx/default.conf @@ -0,0 +1,28 @@ +server { + listen 80; + listen [::]:80; + + location / { + return 301 /pong/web; + } + + location /pong/web/ { + root /usr/share/pong/; + try_files $uri$args $uri$args/ /index.html; + } + + location /pong/api/ { + proxy_pass http://api_server/; + + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} diff --git a/client/nginx/nginx.conf b/client/nginx/nginx.conf new file mode 100644 index 0000000..887f8af --- /dev/null +++ b/client/nginx/nginx.conf @@ -0,0 +1,45 @@ + +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + upstream api_server { + server localhost:4000; + } + + upstream web_client { + server localhost:8080; + } +} diff --git a/src/lib.rs b/client/src/lib.rs similarity index 100% rename from src/lib.rs rename to client/src/lib.rs diff --git a/src/utils.rs b/client/src/utils.rs similarity index 100% rename from src/utils.rs rename to client/src/utils.rs diff --git a/tests/web.rs b/client/tests/web.rs similarity index 100% rename from tests/web.rs rename to client/tests/web.rs diff --git a/www/.bin/create-wasm-app.js b/client/www/.bin/create-wasm-app.js similarity index 100% rename from www/.bin/create-wasm-app.js rename to client/www/.bin/create-wasm-app.js diff --git a/www/.gitignore b/client/www/.gitignore similarity index 100% rename from www/.gitignore rename to client/www/.gitignore diff --git a/www/.travis.yml b/client/www/.travis.yml similarity index 100% rename from www/.travis.yml rename to client/www/.travis.yml diff --git a/www/LICENSE-APACHE b/client/www/LICENSE-APACHE similarity index 100% rename from www/LICENSE-APACHE rename to client/www/LICENSE-APACHE diff --git a/www/LICENSE-MIT b/client/www/LICENSE-MIT similarity index 100% rename from www/LICENSE-MIT rename to client/www/LICENSE-MIT diff --git a/www/README.md b/client/www/README.md similarity index 100% rename from www/README.md rename to client/www/README.md diff --git a/www/bootstrap.js b/client/www/bootstrap.js similarity index 100% rename from www/bootstrap.js rename to client/www/bootstrap.js diff --git a/www/index.html b/client/www/index.html similarity index 100% rename from www/index.html rename to client/www/index.html diff --git a/www/index.js b/client/www/index.js similarity index 100% rename from www/index.js rename to client/www/index.js diff --git a/www/package-lock.json b/client/www/package-lock.json similarity index 100% rename from www/package-lock.json rename to client/www/package-lock.json diff --git a/www/package.json b/client/www/package.json similarity index 100% rename from www/package.json rename to client/www/package.json diff --git a/www/webpack.config.js b/client/www/webpack.config.js similarity index 100% rename from www/webpack.config.js rename to client/www/webpack.config.js diff --git a/server/kafka/Dockerfile b/kafka/Dockerfile similarity index 100% rename from server/kafka/Dockerfile rename to kafka/Dockerfile diff --git a/server/kafka/custom-entrypoint.sh b/kafka/custom-entrypoint.sh similarity index 100% rename from server/kafka/custom-entrypoint.sh rename to kafka/custom-entrypoint.sh diff --git a/server/kafka/kafka-script-proxy/.dockerignore b/kafka/kafka-script-proxy/.dockerignore similarity index 100% rename from server/kafka/kafka-script-proxy/.dockerignore rename to kafka/kafka-script-proxy/.dockerignore diff --git a/server/kafka/kafka-script-proxy/.gitignore b/kafka/kafka-script-proxy/.gitignore similarity index 100% rename from server/kafka/kafka-script-proxy/.gitignore rename to kafka/kafka-script-proxy/.gitignore diff --git a/server/kafka/kafka-script-proxy/Cargo.toml b/kafka/kafka-script-proxy/Cargo.toml similarity index 100% rename from server/kafka/kafka-script-proxy/Cargo.toml rename to kafka/kafka-script-proxy/Cargo.toml diff --git a/server/kafka/kafka-script-proxy/src/main.rs b/kafka/kafka-script-proxy/src/main.rs similarity index 100% rename from server/kafka/kafka-script-proxy/src/main.rs rename to kafka/kafka-script-proxy/src/main.rs diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e69de29