Initial Commit

This commit is contained in:
Paul Makles
2020-01-19 11:55:14 +00:00
commit 8c41a0d00c
8 changed files with 2085 additions and 0 deletions

22
src/routes/account.rs Normal file
View File

@@ -0,0 +1,22 @@
use crate::database;
use bson::{ bson, doc, ordered::OrderedDocument };
#[get("/")]
pub fn root() -> String {
let client = database::get_connection();
let cursor = client.database("revolt").collection("users").find(None, None).unwrap();
let results: Vec<Result<OrderedDocument, mongodb::error::Error>> = cursor.collect();
format!("ok boomer, users: {}", results.len())
}
#[get("/reg")]
pub fn reg() -> String {
let client = database::get_connection();
let col = client.database("revolt").collection("users");
col.insert_one(doc! { "username": "test" }, None).unwrap();
format!("inserted")
}

8
src/routes/mod.rs Normal file
View File

@@ -0,0 +1,8 @@
use rocket::Rocket;
mod account;
pub fn mount(rocket: Rocket) -> Rocket {
rocket
.mount("/api/v1", routes![account::root, account::reg])
}