From a91bae2784828ee5b58df88a4bd1e6eb2e335c64 Mon Sep 17 00:00:00 2001 From: Paul Makles <paulmakles@gmail.com> Date: Mon, 28 Dec 2020 14:54:34 +0000 Subject: [PATCH] Use compose, disable major parts of application. --- build.sh | 2 -- docker-compose.yml | 18 +++++++++++++ monitor.sh | 2 -- remove.sh | 4 --- run.sh | 22 --------------- src/database/mod.rs | 16 +++++------ .../{account.rs => account.disabled.rs} | 0 src/routes/mod.rs | 27 ++++++------------- src/routes/root.rs | 14 +++++----- 9 files changed, 41 insertions(+), 64 deletions(-) delete mode 100644 build.sh create mode 100644 docker-compose.yml delete mode 100644 monitor.sh delete mode 100644 remove.sh delete mode 100644 run.sh rename src/routes/{account.rs => account.disabled.rs} (100%) diff --git a/build.sh b/build.sh deleted file mode 100644 index 55ee6fa..0000000 --- a/build.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -docker build -t revolt --progress plain . \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3164597 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: '2' + +services: + database: + image: mongo + restart: always + web: + build: . + environment: + - REVOLT_MONGO_URI=mongodb://localhost + - REVOLT_PUBLIC_URL=https://local.revolt.chat + - REVOLT_USE_EMAIL_VERIFICATION=0 + - REVOLT_UNSAFE_NO_EMAIL=1 + - REVOLT_UNSAFE_NO_CAPTCHA=1 + ports: + - "8000:8000" + - "9999:9999" + restart: unless-stopped diff --git a/monitor.sh b/monitor.sh deleted file mode 100644 index a15e793..0000000 --- a/monitor.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -docker logs -f revolt diff --git a/remove.sh b/remove.sh deleted file mode 100644 index 58b9af4..0000000 --- a/remove.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -echo "Removing Revolt container." -docker kill revolt -docker rm revolt diff --git a/run.sh b/run.sh deleted file mode 100644 index 755cc51..0000000 --- a/run.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Split at \n instead of space. -# https://unix.stackexchange.com/a/39482 -set -f -IFS=' -' - -input=($(egrep -v '^#' .env)) -prepended=(${input[@]/#/-e\"}) -variables=${prepended[@]/%/\"} - -unset IFS -set +f - -echo "Running Revolt in detached mode." -docker run \ - -d \ - --name revolt \ - -p 8000:8000 \ - -p 9000:9000 \ - $variables \ - revolt diff --git a/src/database/mod.rs b/src/database/mod.rs index d894cbd..118e0fa 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -28,11 +28,11 @@ pub fn get_collection(collection: &str) -> Collection { pub mod migrations; -pub mod channel; -pub mod guild; -pub mod message; -pub mod mutual; -pub mod permissions; -pub mod user; - -pub use permissions::*; +// pub mod channel; +// pub mod guild; +// pub mod message; +// pub mod mutual; +// pub mod permissions; +// pub mod user; + +// pub use permissions::*; diff --git a/src/routes/account.rs b/src/routes/account.disabled.rs similarity index 100% rename from src/routes/account.rs rename to src/routes/account.disabled.rs diff --git a/src/routes/mod.rs b/src/routes/mod.rs index 17e93b4..07c2b91 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,17 +1,16 @@ pub use rocket::http::Status; pub use rocket::response::Redirect; use rocket::Rocket; -use rocket_contrib::json::JsonValue; -use crate::database::Permission; +// use crate::database::Permission; +// use rocket_contrib::json::JsonValue; -pub mod account; -pub mod channel; +/* pub mod channel; pub mod guild; +pub mod user; */ pub mod root; -pub mod user; -#[derive(Responder)] +/* #[derive(Responder)] pub enum Response { #[response()] Result(Status), @@ -63,22 +62,12 @@ impl<'a> Responder<'a, 'static> for Permission { .sized_body(body.len(), Cursor::new(body)) .ok() } -} +} */ pub fn mount(rocket: Rocket) -> Rocket { rocket .mount("/", routes![root::root, root::teapot]) - .mount( - "/account", - routes![ - account::create, - account::verify_email, - account::resend_email, - account::login, - account::token, - ], - ) - .mount( + /*.mount( "/users", routes![ user::me, @@ -128,5 +117,5 @@ pub fn mount(rocket: Rocket) -> Rocket { guild::ban_member, guild::unban_member, ], - ) + )*/ } diff --git a/src/routes/root.rs b/src/routes/root.rs index a6fc7f5..bcede3c 100644 --- a/src/routes/root.rs +++ b/src/routes/root.rs @@ -1,12 +1,12 @@ -use super::Response; use crate::util::variables::{DISABLE_REGISTRATION, HCAPTCHA_SITEKEY, USE_EMAIL, USE_HCAPTCHA}; +use rocket_contrib::json::JsonValue; use mongodb::bson::doc; /// root #[get("/")] -pub async fn root() -> Response { - Response::Success(json!({ +pub async fn root() -> JsonValue { + json!({ "revolt": "0.3.0-alpha", "features": { "registration": !*DISABLE_REGISTRATION, @@ -16,14 +16,14 @@ pub async fn root() -> Response { }, "email": *USE_EMAIL, } - })) + }) } /// I'm a teapot. #[delete("/")] -pub async fn teapot() -> Response { - Response::Teapot(json!({ +pub async fn teapot() -> JsonValue { + json!({ "teapot": true, "can_delete": false - })) + }) } -- GitLab