M api/src/main.rs => api/src/main.rs +3 -0
@@ 28,7 28,10 @@ fn run_migrations(conn: &mut PgConnection) {
conn.run_pending_migrations(MIGRATIONS).unwrap();
}
+mod schema;
+
mod handlers;
+mod models;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
A api/src/models/mod.rs => api/src/models/mod.rs +10 -0
@@ 0,0 1,10 @@
+/*
+ * This file is part of laurelin/api
+ * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
+ *
+ * Licensed under GPL-3.0-only.
+ * See LICENSE for licensing information.
+ */
+
+mod user;
+pub(crate) use user::*;
A api/src/models/user.rs => api/src/models/user.rs +30 -0
@@ 0,0 1,30 @@
+/*
+ * This file is part of laurelin/api
+ * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
+ *
+ * Licensed under GPL-3.0-only.
+ * See LICENSE for licensing information.
+ */
+
+use chrono::NaiveDateTime;
+use diesel::{Insertable, Queryable};
+use serde::{Deserialize, Serialize};
+use uuid::Uuid;
+
+use crate::schema::users;
+
+#[derive(Serialize, Queryable, Insertable)]
+pub(crate) struct User {
+ pub id: Uuid,
+ pub created_at: NaiveDateTime,
+ pub updated_at: NaiveDateTime,
+ pub username: String,
+ pub email: String,
+}
+
+#[derive(Deserialize)]
+pub(crate) struct NewUser {
+ pub username: String,
+ pub email: String,
+ pub password: String,
+}