|
|
|
@ -1,10 +1,7 @@
@@ -1,10 +1,7 @@
|
|
|
|
|
use std::{env, sync::Arc}; |
|
|
|
|
|
|
|
|
|
use axum::{ |
|
|
|
|
extract::Path, |
|
|
|
|
http::StatusCode, |
|
|
|
|
middleware::{from_fn, from_fn_with_state}, |
|
|
|
|
response::{IntoResponse, Redirect}, |
|
|
|
|
routing::{get, post}, |
|
|
|
|
Router, |
|
|
|
|
}; |
|
|
|
@ -13,7 +10,7 @@ use miette::IntoDiagnostic;
@@ -13,7 +10,7 @@ use miette::IntoDiagnostic;
|
|
|
|
|
use sea_orm::Database; |
|
|
|
|
use time::macros::format_description; |
|
|
|
|
use tower::ServiceBuilder; |
|
|
|
|
use tower_http::trace::TraceLayer; |
|
|
|
|
use tower_http::{services::ServeDir, trace::TraceLayer}; |
|
|
|
|
use tracing::info; |
|
|
|
|
use tracing_subscriber::{fmt::time::UtcTime, EnvFilter, FmtSubscriber}; |
|
|
|
|
|
|
|
|
@ -38,6 +35,7 @@ async fn main() -> miette::Result<()> {
@@ -38,6 +35,7 @@ async fn main() -> miette::Result<()> {
|
|
|
|
|
Err(_) => "sqlx=warn", |
|
|
|
|
}; |
|
|
|
|
let domain = env::var("BASE_DOMAIN").ok(); |
|
|
|
|
let static_file_path = env::var("STATIC_FILE_PATH").unwrap_or("static".to_string()); |
|
|
|
|
let charset: Vec<char> = env::var("V_ID_CHARSET") |
|
|
|
|
.unwrap_or("abcdefghijkmnpqrstuwxyz123467890".to_string()) |
|
|
|
|
.chars() |
|
|
|
@ -62,7 +60,9 @@ async fn main() -> miette::Result<()> {
@@ -62,7 +60,9 @@ async fn main() -> miette::Result<()> {
|
|
|
|
|
let db = Database::connect(db_conn.clone()).await.into_diagnostic()?; |
|
|
|
|
utils::migrate_and_seed_db(&db).await.into_diagnostic()?; |
|
|
|
|
if test_data { |
|
|
|
|
utils::insert_dev_test_data(&db, charset.clone(), id_len).await.into_diagnostic()?; |
|
|
|
|
utils::insert_dev_test_data(&db, charset.clone(), id_len) |
|
|
|
|
.await |
|
|
|
|
.into_diagnostic()?; |
|
|
|
|
info!("V_DEV_TEST_DATA is enabled. credentials: dev:a-password"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -79,7 +79,9 @@ async fn main() -> miette::Result<()> {
@@ -79,7 +79,9 @@ async fn main() -> miette::Result<()> {
|
|
|
|
|
|
|
|
|
|
let app = Router::new() |
|
|
|
|
.route("/", get(|| async { "landing page with login form" })) |
|
|
|
|
.route("/404", get(|| async { "404 not found " })) |
|
|
|
|
.route("/gay/login", post(views::auth::login)) // this one's excempt from the login requirement
|
|
|
|
|
.nest_service("/gay/static", ServeDir::new(static_file_path)) |
|
|
|
|
.nest( |
|
|
|
|
"/gay", // everything is under this namespace to avoid blocking possible link uris as much as possible
|
|
|
|
|
Router::new() |
|
|
|
|