diff --git a/.gitignore b/.gitignore index ab951f8..61ae5aa 100644 --- a/.gitignore +++ b/.gitignore @@ -13,10 +13,3 @@ Cargo.lock # MSVC Windows builds of rustc generate these, which store debugging information *.pdb - -# RustRover -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b6e4a49 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "simpleshout" +version = "0.1.0" +edition = "2021" + +[dependencies] +rocket = { version = "0.5.1", features = ["json"] } +sled = { version = "0.34.7", features = ["mutex"] } +toml = "0.8.19" diff --git a/src/channel.rs b/src/channel.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/client.rs b/src/client.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..f9ddd96 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,96 @@ +#[macro_use] extern crate rocket; + +pub mod channel; +pub mod client; +pub mod message; + +pub struct Config { + admin_password: String, + ratelimit: usize, + init_scrollback: usize, + sync_rate: usize, + reserved_usernames: Vec, + banned_words: Vec, + banned_users: Vec, + banned_ips: Vec, +} + +impl Config { + pub fn save(&self) -> bool { + todo!(); + } + pub fn load(path: &str) -> Self { + todo!(); + } +} + +pub struct State { + config: Config, + db: sled::Db, +} + +#[derive(Display, Serialize)] +pub enum ChatResponseStatus { + SUCCESS, + FAILURE +} + +#[derive(Serialize)] +pub struct ChatResponse { + status: ChatResponseStatus, + message: String, +} + + +#[get("/init")] +fn init() -> Json { + todo!(); +} + +#[post("/login")] +fn login() -> Json { + todo!(); +} + +#[post("/create_channel")] +fn create_channel() -> Json { + todo!(); +} + +#[get("/channels")] +fn channels() -> Json { + todo!() +} + +#[post("/join")] +fn join() -> Json { + todo!(); +} + +#[post("/sync")] +fn sync() -> Json { + todo!(); +} + +#[post("/send")] +fn send() -> Json { + todo!(); +} + +#[delete("/delete")] +fn delete() -> Json { + todo!(); +} + +#[post("/ban")] +fn ban() -> Json { + todo!(); +} + +#[launch] +fn rocket() -> _ { + // load config + // create shared config state + // init database, add to shared state + rocket::build().mount("/", routes![init, login, create_channel, channels, join, sync, send, delete, ban]) +} diff --git a/src/message.rs b/src/message.rs new file mode 100644 index 0000000..e69de29