chore(thanos): strip down codebase to just API routes
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use crate::database::*;
|
||||
use crate::util::result::{Error, Result, EmptyResponse};
|
||||
use revolt_quark::{EmptyResponse, Result};
|
||||
use crate::util::regex::RE_USERNAME;
|
||||
|
||||
use mongodb::bson::doc;
|
||||
@@ -15,31 +14,6 @@ pub struct Data {
|
||||
}
|
||||
|
||||
#[post("/complete", data = "<data>")]
|
||||
pub async fn req(session: Session, user: Option<User>, data: Json<Data>) -> Result<EmptyResponse> {
|
||||
if user.is_some() {
|
||||
Err(Error::AlreadyOnboarded)?
|
||||
}
|
||||
|
||||
data.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
if User::is_username_taken(&data.username).await? {
|
||||
return Err(Error::UsernameTaken);
|
||||
}
|
||||
|
||||
get_collection("users")
|
||||
.insert_one(
|
||||
doc! {
|
||||
"_id": session.user_id,
|
||||
"username": &data.username
|
||||
},
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
operation: "insert_one",
|
||||
with: "user",
|
||||
})?;
|
||||
|
||||
Ok(EmptyResponse {})
|
||||
pub async fn req(/*session: Session, user: Option<User>,*/ data: Json<Data>) -> Result<EmptyResponse> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
use crate::database::*;
|
||||
|
||||
use rauth::entities::Session;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[get("/hello")]
|
||||
pub async fn req(_session: Session, user: Option<User>) -> Value {
|
||||
json!({
|
||||
"onboarding": user.is_none()
|
||||
})
|
||||
pub async fn req(/*_session: Session, user: Option<User>*/) -> Value {
|
||||
todo!()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user