refactor: rewrite entire codebase in axum instead of actix

Replaces actix with axum for web, allows us to use socket.io and gives us access to the tower ecosystem of middleware

breaks compatibility with our current websocket implementation, needs to be reimplemented for socket.io
This commit is contained in:
Radical 2025-07-16 16:36:22 +02:00
parent 3647086adb
commit 324137ce8b
47 changed files with 1381 additions and 1129 deletions

View file

@ -1,12 +1,17 @@
use std::time::{SystemTime, UNIX_EPOCH};
use std::{
sync::Arc,
time::{SystemTime, UNIX_EPOCH},
};
use actix_web::{Scope, web};
use axum::{
Router,
routing::{delete, get, post},
};
use diesel::{ExpressionMethods, QueryDsl};
use diesel_async::RunQueryDsl;
use serde::Serialize;
use uuid::Uuid;
use crate::{Conn, error::Error, schema::access_tokens::dsl};
use crate::{AppState, Conn, error::Error, schema::access_tokens::dsl};
mod devices;
mod login;
@ -17,23 +22,18 @@ mod reset_password;
mod revoke;
mod verify_email;
#[derive(Serialize)]
struct Response {
access_token: String,
}
pub fn web() -> Scope {
web::scope("/auth")
.service(register::res)
.service(login::response)
.service(logout::res)
.service(refresh::res)
.service(revoke::res)
.service(verify_email::get)
.service(verify_email::post)
.service(reset_password::get)
.service(reset_password::post)
.service(devices::get)
pub fn router() -> Router<Arc<AppState>> {
Router::new()
.route("/register", post(register::post))
.route("/login", post(login::response))
.route("/logout", delete(logout::res))
.route("/refresh", post(refresh::post))
.route("/revoke", post(revoke::post))
.route("/verify-email", get(verify_email::get))
.route("/verify-email", post(verify_email::post))
.route("/reset-password", get(reset_password::get))
.route("/reset-password", post(reset_password::post))
.route("/devices", get(devices::get))
}
pub async fn check_access_token(access_token: &str, conn: &mut Conn) -> Result<Uuid, Error> {