aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-server/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'atuin-server/src/lib.rs')
-rw-r--r--atuin-server/src/lib.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/atuin-server/src/lib.rs b/atuin-server/src/lib.rs
index e4858811..ca0aa11c 100644
--- a/atuin-server/src/lib.rs
+++ b/atuin-server/src/lib.rs
@@ -1,8 +1,10 @@
#![forbid(unsafe_code)]
-use std::net::IpAddr;
+use std::net::{IpAddr, SocketAddr};
-use eyre::Result;
+use axum::Server;
+use database::Postgres;
+use eyre::{Context, Result};
use crate::settings::Settings;
@@ -19,14 +21,18 @@ pub mod models;
pub mod router;
pub mod settings;
-pub async fn launch(settings: &Settings, host: String, port: u16) -> Result<()> {
- // routes to run:
- // index, register, add_history, login, get_user, sync_count, sync_list
+pub async fn launch(settings: Settings, host: String, port: u16) -> Result<()> {
let host = host.parse::<IpAddr>()?;
- let r = router::router(settings).await?;
+ let postgres = Postgres::new(settings.db_uri.as_str())
+ .await
+ .wrap_err_with(|| format!("failed to connect to db: {}", settings.db_uri))?;
- warp::serve(r).run((host, port)).await;
+ let r = router::router(postgres, settings);
+
+ Server::bind(&SocketAddr::new(host, port))
+ .serve(r.into_make_service())
+ .await?;
Ok(())
}