summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 335649c..d99fbe9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,9 +1,12 @@
+use std::env;
+
use axum::extract::DefaultBodyLimit;
use axum::http::StatusCode;
use axum::response::IntoResponse;
use axum::routing::get;
use axum::Router;
use maud::{html, Markup, DOCTYPE};
+use sqlx::sqlite::SqlitePoolOptions;
use tower_http::services::ServeDir;
struct AppError(anyhow::Error);
@@ -29,6 +32,18 @@ where
#[tokio::main]
async fn main() {
+ let pool = SqlitePoolOptions::new()
+ .connect(
+ &env::var("DATABASE_URL").expect("Failed to get environment variable DATABASE_URL"),
+ )
+ .await
+ .expect("Failed to connect to database");
+
+ sqlx::migrate!()
+ .run(&pool)
+ .await
+ .expect("Failed to run migrations");
+
let app = Router::new()
.route("/", get(home))
.nest_service("/static", ServeDir::new("src/static"))