Initial commit
commit
5e16bb6fd1
|
@ -0,0 +1 @@
|
||||||
|
/target
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,14 @@
|
||||||
|
[package]
|
||||||
|
name = "simple_live_chat"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bincode = "1.3.3"
|
||||||
|
once_cell = "1.8.0"
|
||||||
|
serde = { version = "1.0.126", features = ["derive"] }
|
||||||
|
sled = "0.34.6"
|
||||||
|
tokio = { version = "1.9.0", features = ["full"] }
|
||||||
|
warp = "0.3.1"
|
|
@ -0,0 +1,10 @@
|
||||||
|
use std::sync::Mutex;
|
||||||
|
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
use sled::Db;
|
||||||
|
|
||||||
|
pub static DB: Lazy<Mutex<Db>> = Lazy::new(|| {
|
||||||
|
let db_path = std::env::var("DB_PATH").unwrap_or_else(|_| "user-database.db".to_string());
|
||||||
|
|
||||||
|
Mutex::new(sled::open(db_path).unwrap())
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
use warp::{Filter, Rejection, Reply};
|
||||||
|
|
||||||
|
mod db;
|
||||||
|
mod users;
|
||||||
|
|
||||||
|
async fn hello() -> Result<impl Reply, Rejection> {
|
||||||
|
Ok("Hello!".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
let hello = warp::any().and_then(hello);
|
||||||
|
warp::serve(hello).run(([127, 0, 0, 1], 8000)).await;
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct User {
|
||||||
|
// TODO: What fields does a User need?
|
||||||
|
}
|
Loading…
Reference in New Issue