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