Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove shuttle dependency #14

Merged
merged 5 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/Cargo.lock
/front/dist
.env
.vscode
6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

25 changes: 9 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
[package]
[workspace]
members = ["front", "shared", "api"]

resolver = "2"

[workspace.package]
name = "power-scouter"
version = "0.2.0"
edition = "2021"
publish = false

[workspace]
members = ["front", "shared", "."]

[dependencies]
shuttle-runtime = "0.39.0"
actix-web = "4.3.1"
shuttle-actix-web = "0.39.0"
tokio = "1.26.0"
actix-files = "0.6.2"
serde = "1.0.152"
serde_json = "1.0.94"
tracing = "0.1.40"
shared = { path = "./shared" }
actix-cors = "0.7.0"
mime = "0.3.17"
[workspace.dependencies]
serde = { version = "1.0", features = ['derive'] }
serde_json = "1.0"
11 changes: 6 additions & 5 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[tasks.shuttle]
[tasks.dev]
workspace = false
env = { "RUST_LOG" = "trace" }
install_crate = "cargo-shuttle"
command = "cargo"
args = ["shuttle", "run"]
script_runner = "@shell"
script = '''
cd api
cargo run
'''

[tasks.serve]
workspace = false
Expand Down
15 changes: 15 additions & 0 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "api"
version = "0.2.0"
edition = "2021"
publish = false

[dependencies]
actix-web = "4.8"
tokio = "1.26.0"
actix-files = "0.6"
shared = { path = "../shared" }
serde = { workspace = true }
serde_json = { workspace = true }
tracing = "0.1.40"
mime = "0.3.17"
33 changes: 33 additions & 0 deletions api/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use actix_files::Files;
use actix_web::{
web::{self, scope, Json},
App, HttpServer, Result,
};

use shared::helpers::calculations::calculate_score;
use shared::models::{CompetitorInfo, Score};

async fn hello_world() -> &'static str {
"Hello World!"
}

async fn calculate_results(competitor_info: Json<CompetitorInfo>) -> Result<Json<Score>> {
let results = calculate_score(competitor_info.into_inner());
Ok(Json(results))
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(
scope("/api")
.route("hello", web::get().to(hello_world))
.route("score", web::post().to(calculate_results)),
)
.service(Files::new("/", "../static").index_file("index.html"))
})
.bind("127.0.0.1:8080")?
.run()
.await
}
2 changes: 1 addition & 1 deletion front/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ panic = "abort"
dioxus = "0.4.3"
dioxus-web = "0.4.3"
log = "0.4.17"
reqwest = { version = "0.11", features = ["json"] }
reqwest = { version = "0.12.5", features = ["json"] }
shared = { path = "../shared" }
4 changes: 2 additions & 2 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = "1.0.152"
serde_json = "1.0.94"
serde = { workspace = true }
serde_json = { workspace = true }
35 changes: 0 additions & 35 deletions src/main.rs

This file was deleted.

Loading