Initial Commit

This commit is contained in:
FriederHannenheim 2024-01-17 22:07:06 +01:00
commit c97174301b
6 changed files with 2039 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/target
*.un~
*~

1984
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

10
Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "milimate"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rocket = "0.5.0"
rocket_db_pools = { version = "0.1.0", features = ["diesel_postgres"] }

4
Rocket.toml Normal file
View File

@ -0,0 +1,4 @@
[default.databases.catsen]
url = "./db.sqlite"

24
src/db.rs Normal file
View File

@ -0,0 +1,24 @@
use rocket_db_pools::{Database, Connection};
use rocket_db_pools::diesel::{QueryResult, PgPool, prelude::*};
#[derive(Database)]
#[database("public")]
pub stuct PublicDb(PgPool);
#[derive(Queryable, Insertable)]
#[diesel(table_name = avatar)]
pub struct Avatar {
id: i64,
ident: char,
data: Vec<u8>,
hash: Vec<u8>,
}
diesel::table! {
avatar (id) {
id -> BigInt,
ident -> Char,
data -> Array<u8>,
hash -> Array<u8>,
}
}

14
src/main.rs Normal file
View File

@ -0,0 +1,14 @@
#[macro_use] extern crate rocket;
use db::{PublicDb, Avatar};
mod db;
#[get("/")]
async fn list(mut db: Connection<PublicDb>) -> QueryResult<String> {
avatar::table.load(&mut db)
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![index])
}