blob: 86f6752380bc7754809b8d8e0565d2a8276b4c5c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
pub use error::{Error, Result};
pub mod api;
pub mod auth;
pub mod error;
pub mod state;
pub mod utils;
pub fn router() -> axum::Router<state::AppState> {
axum::Router::new()
.nest("/api", api::router())
.nest("/auth", auth::router())
.layer(tower_http::trace::TraceLayer::new_for_http())
}
#[cfg(test)]
pub(crate) mod tests {
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
pub type TestResult<T = (), E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
pub const JWT_SECRET: &str = "test-jwt-secret-token";
static INIT: std::sync::Once = std::sync::Once::new();
pub fn setup_test_env() {
INIT.call_once(|| {
tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::from_default_env())
.with(tracing_subscriber::fmt::layer().with_test_writer())
.init();
std::env::set_var("JWT_SECRET", JWT_SECRET);
});
}
}
|