diff --git a/src/api/routes/health.rs b/src/api/routes/health.rs index c264b98..7fe4f55 100644 --- a/src/api/routes/health.rs +++ b/src/api/routes/health.rs @@ -1,11 +1,9 @@ -use rocket::Rocket; +use rocket::{Rocket}; -#[get("/health")] -fn check() -> &'static str { - "OK" -} +#[get("/")] +fn check() -> &'static str { "OK" } pub fn fuel(rocket: Rocket) -> Rocket { - rocket.mount("/api", routes![check]) + rocket.mount("/api/health", routes![check]) } \ No newline at end of file diff --git a/src/api/routes/paste.rs b/src/api/routes/paste.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/core/mod.rs b/src/core/mod.rs index 8be33e3..304e7af 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -1 +1,2 @@ -pub mod paste; \ No newline at end of file +pub mod paste; +pub mod users; \ No newline at end of file diff --git a/src/core/paste/diesel.rs b/src/core/paste/diesel.rs index e69de29..85bd16c 100644 --- a/src/core/paste/diesel.rs +++ b/src/core/paste/diesel.rs @@ -0,0 +1,11 @@ +use diesel::pg::PgConnection; +use diesel::result::Error; +use super::entity::Paste; +use crate::schema::pastes; +use diesel::{RunQueryDsl, QueryResult}; + +pub fn create(paste: &Paste, conn: &PgConnection) -> Result { + diesel::insert_into(pastes::table) + .values(paste) + .execute(conn) +} \ No newline at end of file diff --git a/src/core/paste/entity.rs b/src/core/paste/entity.rs index e69de29..85d2701 100644 --- a/src/core/paste/entity.rs +++ b/src/core/paste/entity.rs @@ -0,0 +1,10 @@ +use crate::schema::pastes; + +#[table_name="pastes"] +#[derive(AsChangeset, Serialize, Deserialize, Queryable, Insertable)] +pub struct Paste { + id: String, + belongs_to: String, + is_url: bool, + content: String +} \ No newline at end of file diff --git a/src/core/users/diesel.rs b/src/core/users/diesel.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/core/users/entity.rs b/src/core/users/entity.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/core/users/mod.rs b/src/core/users/mod.rs new file mode 100644 index 0000000..2c2c2d0 --- /dev/null +++ b/src/core/users/mod.rs @@ -0,0 +1,4 @@ +pub mod diesel; +pub mod entity; +pub mod repository; +pub mod service; \ No newline at end of file diff --git a/src/core/users/repository.rs b/src/core/users/repository.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/core/users/service.rs b/src/core/users/service.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs index b84c92c..7a0380b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,7 @@ extern crate slog; pub mod api; pub mod core; pub mod utils; +pub mod schema; use slog_term; use slog_async; diff --git a/src/schema.rs b/src/schema.rs index 1564ab4..260832c 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -1,12 +1,3 @@ -table! { - games (id) { - id -> Int4, - name -> Text, - developer -> Text, - is_goty -> Bool, - } -} - table! { pastes (id) { id -> Varchar, @@ -28,7 +19,6 @@ table! { joinable!(pastes -> users (belongs_to)); allow_tables_to_appear_in_same_query!( - games, pastes, users, );