Scrapping the APi because rocket is not mature enough for this project
This commit is contained in:
1602
api/Cargo.lock
generated
1602
api/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,10 +0,0 @@
|
||||
[package]
|
||||
name = "api"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "1", features = [ "full" ] }
|
||||
serde = "1.0.213"
|
||||
rocket = { version = "0.5.1", features = [ "json" ] }
|
||||
clap = { version = "4.5.20", features = ["derive"] }
|
||||
@@ -1,41 +0,0 @@
|
||||
use serde::Serialize;
|
||||
use rocket::serde::json::Json;
|
||||
|
||||
#[derive(Serialize)]
|
||||
enum Type {
|
||||
Voice,
|
||||
Text,
|
||||
Video
|
||||
}
|
||||
#[derive(Serialize)]
|
||||
struct Channel {
|
||||
id: i64,
|
||||
name: String,
|
||||
desc: Option<String>,
|
||||
r#type: Type
|
||||
}
|
||||
|
||||
#[get("/list")]
|
||||
pub async fn list() -> Json<Vec<Channel>> {
|
||||
// TODO
|
||||
Json(vec![])
|
||||
}
|
||||
|
||||
#[post("/create")]
|
||||
pub async fn create() -> Json<Option<Channel>> {
|
||||
// TODO
|
||||
Json(None)
|
||||
}
|
||||
|
||||
#[delete("/delete")]
|
||||
pub async fn delete() -> Json<Option<i64>> {
|
||||
// TODO
|
||||
Json(None)
|
||||
}
|
||||
|
||||
#[post("/update")]
|
||||
pub async fn update() -> Json<Option<Channel>> {
|
||||
// TODO
|
||||
Json(None)
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
use rocket::serde::json::Json;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct User {
|
||||
id: i64,
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[get("/<id>")]
|
||||
pub async fn invite_user(id: i64) -> Json<Option<User>> {
|
||||
// First we check to see if the id is present in the invites table
|
||||
Json(None)
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#[macro_use] extern crate rocket;
|
||||
use std::env;
|
||||
|
||||
use clap::Parser;
|
||||
mod invites;
|
||||
mod channels;
|
||||
|
||||
struct Config {
|
||||
postgres_user: String,
|
||||
postgrse_pass: String
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Args {
|
||||
/// Set the postgres username to use for the API ( default is bubble_admin )
|
||||
#[arg(short, long, default_value = "bubble_admin")]
|
||||
psql_user: String,
|
||||
/// Set the postgres password to use for the API ( Uses POSTGRES_PASSWORD
|
||||
/// environment variable by default )
|
||||
psql_pass: Option<String>,
|
||||
|
||||
}
|
||||
|
||||
|
||||
#[rocket::main]
|
||||
async fn main() -> Result<(), rocket::Error> {
|
||||
let args = Args::parse();
|
||||
let psql_pass = match args.psql_pass {
|
||||
Some(pass) => pass,
|
||||
None => match env::var("PSQL_PASS") {
|
||||
Ok(pass) => pass,
|
||||
Err(_) => panic!("PSQL_PASS is not set!")
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
let _ = rocket::build()
|
||||
.mount("/channels", routes![
|
||||
channels::list,
|
||||
channels::create,
|
||||
channels::delete
|
||||
])
|
||||
.mount("/invite", routes![invites::invite_user])
|
||||
.ignite().await?
|
||||
.launch().await?;
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user