Skip to content

Commit 4b9be82

Browse files
committed
housekeeping
1 parent 4a50292 commit 4b9be82

File tree

15 files changed

+31
-148
lines changed

15 files changed

+31
-148
lines changed

src/app.rs

+31-66
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,43 @@
1-
use std::collections::HashMap;
2-
3-
use std::path::Path;
4-
use std::env;
5-
6-
use std::sync::{Arc, Mutex};
7-
use tokio::time::{self};
1+
use std::{
2+
env,
3+
path::Path,
4+
sync::Arc,
5+
{net::SocketAddr, path::PathBuf}
6+
};
7+
use tokio::time;
88
use async_trait::async_trait;
9+
use migration::Migrator;
10+
use sea_orm::DatabaseConnection;
11+
use reqwest::Client;
12+
use tower_http::normalize_path::NormalizePathLayer;
13+
use tower_layer::Layer;
14+
use axum_server::tls_rustls::RustlsConfig;
15+
use axum::{
16+
extract::Host,
17+
handler::HandlerWithoutStateExt,
18+
http::{StatusCode, Uri},
19+
response::Redirect, Extension,
20+
};
921
use loco_rs::{
1022
app::{AppContext, Hooks, Initializer},
1123
boot::{create_app, BootResult, StartMode},
1224
controller::AppRoutes,
13-
db::{self, truncate_table},
25+
db::truncate_table,
1426
environment::Environment,
1527
task::Tasks,
1628
worker::{AppWorker, Processor},
1729
Result,
1830
};
19-
use migration::{Migrator};
20-
use sea_orm::DatabaseConnection;
21-
use serde::{Deserialize, Serialize};
2231

2332
use crate::{
24-
controllers, initializers,
25-
models::_entities::{devices, notes, users},
2633
tasks,
34+
controllers,
35+
initializers,
36+
controllers::ws::ConnectionManager,
37+
models::_entities::{devices, users},
2738
};
2839

29-
use reqwest::{Client};
30-
use tower_http::normalize_path::NormalizePathLayer;
31-
use tower_layer::Layer;
32-
use tokio::sync::{mpsc, oneshot, RwLock};
33-
34-
use axum::{
35-
extract::Host,
36-
handler::HandlerWithoutStateExt,
37-
http::{StatusCode, Uri},
38-
response::Redirect, Extension,
39-
};
40-
use axum_server::tls_rustls::RustlsConfig;
41-
use std::{net::SocketAddr, path::PathBuf};
42-
43-
44-
#[derive(Serialize, Deserialize, Clone)]
45-
struct JsonRpcCommand {
46-
id: String,
47-
method: String,
48-
params: serde_json::Value,
49-
}
50-
51-
#[derive(Serialize, Deserialize, Clone)]
52-
struct JsonRpcResponse {
53-
id: String,
54-
result: Option<serde_json::Value>,
55-
error: Option<serde_json::Value>,
56-
}
57-
58-
type SharedState = Arc<RwLock<App>>;
59-
60-
use crate::controllers::ws::ConnectionManager;
61-
62-
pub struct App {
63-
// command_sender: mpsc::Sender<JsonRpcCommand>,
64-
// pending_commands: Arc<Mutex<HashMap<String, oneshot::Sender<JsonRpcResponse>>>>,
65-
// offline_queues: Arc<Mutex<HashMap<String, Vec<JsonRpcCommand>>>>, // offline queue for each device
66-
}
40+
pub struct App {}
6741
#[async_trait]
6842
impl Hooks for App {
6943
fn app_name() -> &'static str {
@@ -123,14 +97,13 @@ impl Hooks for App {
12397

12498
async fn truncate(db: &DatabaseConnection) -> Result<()> {
12599
truncate_table(db, users::Entity).await?;
126-
truncate_table(db, notes::Entity).await?;
127100
Ok(())
128101
}
129102

130-
async fn seed(db: &DatabaseConnection, base: &Path) -> Result<()> {
131-
db::seed::<users::ActiveModel>(db, &base.join("users.yaml").display().to_string()).await?;
103+
async fn seed(_db: &DatabaseConnection, _base: &Path) -> Result<()> {
104+
//db::seed::<users::ActiveModel>(db, &base.join("users.yaml").display().to_string()).await?;
132105
//db::seed::<notes::ActiveModel>(db, &base.join("notes.yaml").display().to_string()).await?;
133-
db::seed::<devices::ActiveModel>(db, &base.join("devices.yaml").display().to_string()).await?;
106+
//db::seed::<devices::ActiveModel>(db, &base.join("devices.yaml").display().to_string()).await?;
134107
//db::seed::<routes::ActiveModel>(db, &base.join("routes.yaml").display().to_string()).await?;
135108
//db::seed::<segments::ActiveModel>(db, &base.join("segments.yaml").display().to_string()).await?;
136109
Ok(())
@@ -159,20 +132,10 @@ impl Hooks for App {
159132
}
160133
});
161134

162-
163-
164-
//let (command_sender, _command_receiver) = mpsc::channel(100);
165-
// let shared_state: Arc<RwLock<App>> = Arc::new(RwLock::new(App {
166-
// command_sender,
167-
// pending_commands: Arc::new(Mutex::new(HashMap::new())),
168-
// offline_queues: Arc::new(Mutex::new(HashMap::new())),
169-
// }));
170135
let client = Client::new();
171-
172136
let router = router
173137
.layer(Extension(client))
174138
.layer(Extension(connection_manager));
175-
//.layer(Extension(shared_state));
176139

177140
Ok(router)
178141
}
@@ -241,6 +204,7 @@ struct MyServerConfig {
241204
binding: String
242205
}
243206

207+
/*
244208
async fn redirect_http_to_https(my_server_config: MyServerConfig) {
245209
let config_clone = my_server_config.clone(); // Clone the config for the closure
246210
@@ -274,4 +238,5 @@ async fn redirect_http_to_https(my_server_config: MyServerConfig) {
274238
axum::serve(listener, redirect.into_make_service())
275239
.await
276240
.unwrap();
277-
}
241+
}
242+
*/

src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
pub mod app;
22
pub mod controllers;
33
pub mod initializers;
4-
pub mod mailers;
54
pub mod models;
65
pub mod tasks;
76
pub mod views;

src/mailers/auth.rs

-19
This file was deleted.

src/mailers/auth/forgot/html.t

-11
This file was deleted.

src/mailers/auth/forgot/subject.t

-1
This file was deleted.

src/mailers/auth/forgot/text.t

-3
This file was deleted.

src/mailers/auth/welcome/html.t

-13
This file was deleted.

src/mailers/auth/welcome/subject.t

-1
This file was deleted.

src/mailers/auth/welcome/text.t

-4
This file was deleted.

src/mailers/mod.rs

-1
This file was deleted.

src/models/_entities/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pub mod authorized_users;
77
pub mod bootlogs;
88
pub mod device_msg_queues;
99
pub mod devices;
10-
pub mod notes;
1110
pub mod routes;
1211
pub mod segments;
1312
pub mod users;

src/models/_entities/notes.rs

-18
This file was deleted.

src/models/_entities/prelude.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pub use super::authorized_users::Entity as AuthorizedUsers;
55
pub use super::bootlogs::Entity as Bootlogs;
66
pub use super::device_msg_queues::Entity as DeviceMsgQueues;
77
pub use super::devices::Entity as Devices;
8-
pub use super::notes::Entity as Notes;
98
pub use super::routes::Entity as Routes;
109
pub use super::segments::Entity as Segments;
1110
pub use super::users::Entity as Users;

src/models/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pub mod _entities;
2-
pub mod notes;
32
pub mod users;
43
pub mod devices;
54
pub mod segments;

src/models/notes.rs

-7
This file was deleted.

0 commit comments

Comments
 (0)