Compare commits

...

2 Commits

4 changed files with 22 additions and 2 deletions

17
back/Cargo.lock generated
View File

@ -939,6 +939,7 @@ dependencies = [
"serde",
"sqlx",
"tokio",
"tower-http",
"tracing-subscriber",
]
@ -1575,6 +1576,22 @@ dependencies = [
"tracing",
]
[[package]]
name = "tower-http"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5"
dependencies = [
"bitflags 2.6.0",
"bytes",
"http",
"http-body",
"http-body-util",
"pin-project-lite",
"tower-layer",
"tower-service",
]
[[package]]
name = "tower-layer"
version = "0.3.2"

View File

@ -8,4 +8,5 @@ axum = "0.7.5"
serde = "1.0.204"
sqlx = { version = "0.7.4", features = ["runtime-tokio", "sqlite"] }
tokio = { version = "1.38.1", features = ["rt-multi-thread", "macros", "net", "time", "sync"] }
tower-http = { version = "0.5.2", features = ["cors"] }
tracing-subscriber = "0.3.18"

View File

@ -3,6 +3,7 @@ use std::str::FromStr;
use axum::{
extract::State, http::StatusCode, routing::post, Json, Router
};
use tower_http::cors::CorsLayer;
use sqlx::{Row, sqlite::{SqliteConnectOptions, SqlitePoolOptions}, Pool, Sqlite};
@ -48,6 +49,7 @@ async fn main() {
.route("/api/echo", post(echo))
.route("/api/get_counter", post(get_counter))
.route("/api/set_counter", post(set_counter))
.layer(CorsLayer::permissive())
.with_state(state);
axum::serve(listener, app)

View File

@ -27,14 +27,14 @@
backend = platform.buildRustPackage {
name = "plantback";
src = ./back;
cargoLock = { lockFile = ./front/Cargo.lock; };
cargoLock = { lockFile = ./back/Cargo.lock; };
};
frontend = pkgs.buildNpmPackage {
name = "plantfront";
src = ./front;
nodejs = node;
npmBuildScript = "build-only";
npmDepsHash = "sha256-QYmO99RkdhAN+vNOkBqeXYlfyHGyHfRKVVMIWYfZO1A=";
npmDepsHash = "sha256-0BTgt0zjKa6NPEAPyqJEkej0LuhglKpx645JpVSE2Ag=";
installPhase = ''
mv ./dist $out
'';