Skip to content

Commit

Permalink
Maps and things
Browse files Browse the repository at this point in the history
  • Loading branch information
timmo001 committed Jun 8, 2024
1 parent a42a575 commit 98bc3e5
Show file tree
Hide file tree
Showing 4 changed files with 364 additions and 310 deletions.
1 change: 1 addition & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ log = "0.4.21"
mac_address = "1.1.7"
machine-uid = "0.5.1"
notify = "6.1.1"
once_cell = "1.19.0"
platform-dirs = "0.3.0"
pyo3 = { version = "0.21.2", features = ["auto-initialize"] }
reqwest = "0.12.4"
Expand Down
8 changes: 6 additions & 2 deletions src-tauri/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ mod routes;

use crate::{
settings::{get_settings, Settings},
websocket::server::websocket,
websocket::server::{websocket, PeersMap},
};
use log::info;
use rocket::tokio::sync::Mutex;
use rocket::{catchers, routes};
use routes::{api, data, data_key, not_found, root};
use std::error::Error;
use std::{collections::HashMap, error::Error, sync::Arc};

pub async fn setup_api() -> Result<(), Box<dyn Error>> {
// Get settings
Expand All @@ -20,9 +21,12 @@ pub async fn setup_api() -> Result<(), Box<dyn Error>> {
config.address = std::net::IpAddr::from([0, 0, 0, 0]);
config.port = settings.api.port as u16;

let peers_map: PeersMap = Arc::new(Mutex::new(HashMap::new()));

let _rocket = rocket::build()
.configure(config)
.register("/", catchers![not_found])
.manage(peers_map)
.mount("/", routes![root, api, data, data_key, websocket])
.launch()
.await?;
Expand Down
Loading

0 comments on commit 98bc3e5

Please sign in to comment.