diff --git a/clippable-server/src/api.rs b/clippable-server/src/api.rs index 144aae4..7d690ac 100644 --- a/clippable-server/src/api.rs +++ b/clippable-server/src/api.rs @@ -1,4 +1,36 @@ -#[get("/")] -fn video_page() -> String { - format!("TODO") +use rocket_contrib::json::Json; +use rocket_contrib::json::JsonValue; +use dblib::{DB, request::ApiKey}; +use dblib::KeyStore; +use serde::Serialize; + +#[derive(Serialize)] +pub struct GenericResponse<'m> { + msg: Option<&'m str>, + err: bool } + +#[get("/by-id")] +pub fn get_vid_by_id(id: String) -> JsonValue { + todo!() +} + +#[get("/by-name")] +pub fn get_vid_by_name(name: String) -> JsonValue { + todo!() +} + +#[update("/description?&")] +pub fn update_description<'m>(key: ApiKey, id: String, desc: String) -> Json> { + todo!() +} + +#[delete("/video?")] +pub fn delete_video(key: ApiKey, id: String) -> Json> { + todo!() +} + +#[update("/name?&")] +pub fn update_vid_name<'m>(key: ApiKey, id: String, dest: String) -> Json> { + todo!() +} \ No newline at end of file diff --git a/clippable-server/src/main.rs b/clippable-server/src/main.rs index 277861e..ff534c7 100644 --- a/clippable-server/src/main.rs +++ b/clippable-server/src/main.rs @@ -3,6 +3,7 @@ use rocket_contrib::serve::StaticFiles; use std::env; +mod api; #[get("/")] fn video_page(id: u64) -> String { @@ -14,7 +15,14 @@ fn main() { env::set_var("ROCKET_CLI_COLORS", "off"); let _ = rocket::ignite() - .mount("/video", routes![video_page]) + .mount("/clip", routes![video_page]) + .mount("/video-api", routes![ + api::get_vid_by_id, + api::get_vid_by_name, + api::update_description, + api::delete_video, + api::update_vid_name, + ]) .mount("/", StaticFiles::from("static")) .launch(); }