aboutsummaryrefslogtreecommitdiffstats
path: root/src/remote/database.rs
diff options
context:
space:
mode:
authorEllie Huxtable <e@elm.sh>2021-03-21 20:04:39 +0000
committerGitHub <noreply@github.com>2021-03-21 20:04:39 +0000
commitc9579cb9ca2a6a165d10f128e0af1dfd372e0c03 (patch)
tree1d4feecb422aae3cde1cc7cad54ccc73b2dae410 /src/remote/database.rs
parentAdd TUI, resolve #19, #17, #16 (#21) (diff)
downloadatuin-c9579cb9ca2a6a165d10f128e0af1dfd372e0c03.zip
Implement server (#23)
* Add initial database and server setup * Set up all routes, auth, etc * Implement sessions, password auth, hashing with argon2, and history storage
Diffstat (limited to '')
-rw-r--r--src/remote/database.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/remote/database.rs b/src/remote/database.rs
new file mode 100644
index 00000000..4f386def
--- /dev/null
+++ b/src/remote/database.rs
@@ -0,0 +1,14 @@
+use diesel::pg::PgConnection;
+use diesel::prelude::*;
+
+use crate::settings::Settings;
+
+#[database("atuin")]
+pub struct AtuinDbConn(diesel::PgConnection);
+
+// TODO: connection pooling
+pub fn establish_connection(settings: &Settings) -> PgConnection {
+ let database_url = &settings.remote.db.url;
+ PgConnection::establish(database_url)
+ .unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
+}