list warrens + explore nested folders
This commit is contained in:
@@ -1,11 +1,32 @@
|
||||
use std::{env, error::Error};
|
||||
use std::env;
|
||||
|
||||
use axum::Router;
|
||||
use axum::http::HeaderValue;
|
||||
use sqlx::{Pool, Postgres};
|
||||
use tokio::net::TcpListener;
|
||||
use tower_http::services::ServeDir;
|
||||
use tower_http::{
|
||||
cors::{self, CorsLayer},
|
||||
services::ServeDir,
|
||||
};
|
||||
|
||||
pub(super) async fn start() -> Result<(), Box<dyn Error>> {
|
||||
let mut app = Router::new();
|
||||
use crate::{
|
||||
Result,
|
||||
api::{self, AppState},
|
||||
};
|
||||
|
||||
pub type Router = axum::Router<AppState>;
|
||||
|
||||
pub(super) async fn start(pool: Pool<Postgres>) -> Result<()> {
|
||||
let cors_origin = env::var("CORS_ALLOW_ORIGIN").unwrap_or("*".to_string());
|
||||
let serve_dir = std::env::var("SERVE_DIRECTORY")?;
|
||||
|
||||
let mut app = Router::new()
|
||||
.nest("/api", api::router())
|
||||
.layer(
|
||||
CorsLayer::new().allow_origin(cors::AllowOrigin::exact(HeaderValue::from_str(
|
||||
&cors_origin,
|
||||
)?)),
|
||||
)
|
||||
.with_state(AppState::new(pool, serve_dir));
|
||||
|
||||
if !cfg!(debug_assertions) {
|
||||
let frontend_path = env::var("STATIC_FRONTEND_DIR").unwrap_or("./frontend".to_string());
|
||||
|
||||
Reference in New Issue
Block a user