feat: remove dependency on socket.io
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
Keeping stuff commented so we can revisit, currently just need a working version
This commit is contained in:
parent
2fb7e7781f
commit
8ec1610b2e
4 changed files with 16 additions and 21 deletions
|
@ -38,10 +38,10 @@ bindet = "0.3.2"
|
||||||
bunny-api-tokio = { version = "0.4", features = ["edge_storage"], default-features = false }
|
bunny-api-tokio = { version = "0.4", features = ["edge_storage"], default-features = false }
|
||||||
|
|
||||||
# Web Server
|
# Web Server
|
||||||
axum = { version = "0.8.4", features = ["macros", "multipart", "ws"] }
|
axum = { version = "0.8.4", features = ["multipart", "ws"] }
|
||||||
tower-http = { version = "0.6.6", features = ["cors"] }
|
tower-http = { version = "0.6.6", features = ["cors"] }
|
||||||
axum-extra = { version = "0.10.1", features = ["cookie", "typed-header"] }
|
axum-extra = { version = "0.10.1", features = ["cookie", "typed-header"] }
|
||||||
socketioxide = { version = "0.17.2", features = ["state"] }
|
#socketioxide = { version = "0.17.2", features = ["state"] }
|
||||||
url = { version = "2.5", features = ["serde"] }
|
url = { version = "2.5", features = ["serde"] }
|
||||||
time = "0.3.41"
|
time = "0.3.41"
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ pub struct RevokeRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Should maybe be a delete request?
|
// TODO: Should maybe be a delete request?
|
||||||
#[axum::debug_handler]
|
|
||||||
pub async fn post(
|
pub async fn post(
|
||||||
State(app_state): State<Arc<AppState>>,
|
State(app_state): State<Arc<AppState>>,
|
||||||
Extension(CurrentUser(uuid)): Extension<CurrentUser<Uuid>>,
|
Extension(CurrentUser(uuid)): Extension<CurrentUser<Uuid>>,
|
||||||
|
|
|
@ -1,20 +1,23 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
Router,
|
middleware::from_fn_with_state, routing::{any, delete, get, patch}, Router
|
||||||
routing::{any, delete, get, patch},
|
|
||||||
};
|
};
|
||||||
//use socketioxide::SocketIo;
|
//use socketioxide::SocketIo;
|
||||||
|
|
||||||
use crate::AppState;
|
use crate::{api::v1::auth::CurrentUser, AppState};
|
||||||
|
|
||||||
mod uuid;
|
mod uuid;
|
||||||
|
|
||||||
pub fn router() -> Router<Arc<AppState>> {
|
pub fn router(app_state: Arc<AppState>) -> Router<Arc<AppState>> {
|
||||||
Router::new()
|
let router_with_auth = Router::new()
|
||||||
.route("/{uuid}", get(uuid::get))
|
.route("/{uuid}", get(uuid::get))
|
||||||
.route("/{uuid}", delete(uuid::delete))
|
.route("/{uuid}", delete(uuid::delete))
|
||||||
.route("/{uuid}", patch(uuid::patch))
|
.route("/{uuid}", patch(uuid::patch))
|
||||||
.route("/{uuid}/socket", any(uuid::socket::ws))
|
|
||||||
.route("/{uuid}/messages", get(uuid::messages::get))
|
.route("/{uuid}/messages", get(uuid::messages::get))
|
||||||
|
.layer(from_fn_with_state(app_state, CurrentUser::check_auth_layer));
|
||||||
|
|
||||||
|
Router::new()
|
||||||
|
.route("/{uuid}/socket", any(uuid::socket::ws))
|
||||||
|
.merge(router_with_auth)
|
||||||
}
|
}
|
||||||
|
|
17
src/main.rs
17
src/main.rs
|
@ -10,7 +10,6 @@ use diesel_async::pooled_connection::deadpool::Pool;
|
||||||
use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations};
|
use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations};
|
||||||
use error::Error;
|
use error::Error;
|
||||||
use objects::MailClient;
|
use objects::MailClient;
|
||||||
use socketioxide::SocketIo;
|
|
||||||
use std::{sync::Arc, time::SystemTime};
|
use std::{sync::Arc, time::SystemTime};
|
||||||
use tower_http::cors::{AllowOrigin, CorsLayer};
|
use tower_http::cors::{AllowOrigin, CorsLayer};
|
||||||
|
|
||||||
|
@ -24,7 +23,7 @@ mod config;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod objects;
|
pub mod objects;
|
||||||
pub mod schema;
|
pub mod schema;
|
||||||
mod socket;
|
//mod socket;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
mod wordlist;
|
mod wordlist;
|
||||||
|
|
||||||
|
@ -53,12 +52,6 @@ pub struct AppState {
|
||||||
async fn main() -> Result<(), Error> {
|
async fn main() -> Result<(), Error> {
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
//SimpleLogger::new()
|
|
||||||
// .with_level(log::LevelFilter::Info)
|
|
||||||
// .with_colors(true)
|
|
||||||
// .env()
|
|
||||||
// .init()
|
|
||||||
// .unwrap();
|
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
let config = ConfigBuilder::load(args.config).await?.build();
|
let config = ConfigBuilder::load(args.config).await?.build();
|
||||||
|
@ -158,12 +151,12 @@ async fn main() -> Result<(), Error> {
|
||||||
// Allow credentials
|
// Allow credentials
|
||||||
.allow_credentials(true);
|
.allow_credentials(true);
|
||||||
|
|
||||||
let (socket_io, io) = SocketIo::builder()
|
/*let (socket_io, io) = SocketIo::builder()
|
||||||
.with_state(app_state.clone())
|
.with_state(app_state.clone())
|
||||||
.build_layer();
|
.build_layer();
|
||||||
|
|
||||||
io.ns("/", socket::on_connect);
|
io.ns("/", socket::on_connect);
|
||||||
|
*/
|
||||||
// build our application with a route
|
// build our application with a route
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
// `GET /` goes to `root`
|
// `GET /` goes to `root`
|
||||||
|
@ -172,8 +165,8 @@ async fn main() -> Result<(), Error> {
|
||||||
app_state.clone(),
|
app_state.clone(),
|
||||||
))
|
))
|
||||||
.with_state(app_state)
|
.with_state(app_state)
|
||||||
.layer(cors)
|
//.layer(socket_io)
|
||||||
.layer(socket_io);
|
.layer(cors);
|
||||||
|
|
||||||
// run our app with hyper, listening globally on port 3000
|
// run our app with hyper, listening globally on port 3000
|
||||||
let listener = tokio::net::TcpListener::bind(web.ip + ":" + &web.port.to_string()).await?;
|
let listener = tokio::net::TcpListener::bind(web.ip + ":" + &web.port.to_string()).await?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue