aboutsummaryrefslogtreecommitdiffstats
path: root/src/remote/server.rs
diff options
context:
space:
mode:
authorEllie Huxtable <e@elm.sh>2021-04-20 17:07:11 +0100
committerGitHub <noreply@github.com>2021-04-20 16:07:11 +0000
commit34888827f8a06de835cbe5833a06914f28cce514 (patch)
tree8b56f20e50065cd2c222d5e8e067ec55cf1947a1 /src/remote/server.rs
parentOptimise docker (#34) (diff)
downloadatuin-34888827f8a06de835cbe5833a06914f28cce514.zip
Switch to Warp + SQLx, use async, switch to Rust stable (#36)
* Switch to warp + sql, use async and stable rust * Update CI to use stable
Diffstat (limited to 'src/remote/server.rs')
-rw-r--r--src/remote/server.rs61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/remote/server.rs b/src/remote/server.rs
deleted file mode 100644
index ee481ca4..00000000
--- a/src/remote/server.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-use std::collections::HashMap;
-
-use crate::remote::database::establish_connection;
-use crate::settings::Settings;
-
-use super::database::AtuinDbConn;
-
-use eyre::Result;
-use rocket::config::{Config, Environment, LoggingLevel, Value};
-
-// a bunch of these imports are generated by macros, it's easier to wildcard
-#[allow(clippy::clippy::wildcard_imports)]
-use super::views::*;
-
-#[allow(clippy::clippy::wildcard_imports)]
-use super::auth::*;
-
-embed_migrations!("migrations");
-
-pub fn launch(settings: &Settings, host: String, port: u16) -> Result<()> {
- let settings: Settings = settings.clone(); // clone so rocket can manage it
-
- let mut database_config = HashMap::new();
- let mut databases = HashMap::new();
-
- database_config.insert("url", Value::from(settings.server.db_uri.clone()));
- databases.insert("atuin", Value::from(database_config));
-
- let connection = establish_connection(&settings)?;
-
- embedded_migrations::run(&connection).expect("failed to run migrations");
-
- let config = Config::build(Environment::Production)
- .address(host)
- .log_level(LoggingLevel::Normal)
- .port(port)
- .extra("databases", databases)
- .finalize()
- .unwrap();
-
- let app = rocket::custom(config);
-
- app.mount(
- "/",
- routes![
- index,
- register,
- add_history,
- login,
- get_user,
- sync_count,
- sync_list
- ],
- )
- .manage(settings)
- .attach(AtuinDbConn::fairing())
- .register(catchers![internal_error, bad_request])
- .launch();
-
- Ok(())
-}