Release: NX9-Auth v0.3.0
This commit is contained in:
1 parent
6a04d7f793
commit
d93f2cef95
92 files changed
+2418
-1143
No files matched your search
+4
-46
@@ -1,14 +1,10 @@
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use clap::Parser;
|
||||
use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
use nx9_auth::{
|
||||
api,
|
||||
cli::{self, Cli, Commands},
|
||||
config::Config,
|
||||
db,
|
||||
state::AppState,
|
||||
runtime::{Application, Lifecycle},
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
@@ -105,46 +101,8 @@ async fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Start the HTTP server (Milestone B+).
|
||||
/// Start the HTTP server using the runtime lifecycle.
|
||||
async fn run_server(config: Config) -> anyhow::Result<()> {
|
||||
// Refuse insecure production configuration (Secure cookies / HSTS surface).
|
||||
config.server.validate_production_security()?;
|
||||
|
||||
// Open DB pool and run migrations
|
||||
let pool = db::create_pool(&config.database.path).await?;
|
||||
db::run_migrations(&pool).await?;
|
||||
|
||||
let pool_clone = pool.clone();
|
||||
tokio::spawn(async move {
|
||||
let _ = pool_clone; // TODO: restore session repo cleanup logic using the new provider architecture
|
||||
});
|
||||
|
||||
let provider: std::sync::Arc<dyn db::provider::DatabaseProvider> =
|
||||
std::sync::Arc::new(db::provider::SqliteProvider::new(pool));
|
||||
|
||||
let state = AppState::new(provider.clone(), config.clone());
|
||||
let app = api::router::build(state);
|
||||
let addr: SocketAddr = format!("{}:{}", config.server.host, config.server.port)
|
||||
.parse()
|
||||
.map_err(|e| anyhow::anyhow!("invalid bind address: {}", e))?;
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(addr).await?;
|
||||
|
||||
tracing::info!(
|
||||
address = %addr,
|
||||
"server listening"
|
||||
);
|
||||
|
||||
println!(
|
||||
"\nnx9-auth is running\n\n API + Admin UI : http://{}\n Health check : http://{}/health\n",
|
||||
addr, addr
|
||||
);
|
||||
|
||||
axum::serve(
|
||||
listener,
|
||||
app.into_make_service_with_connect_info::<SocketAddr>(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
let mut app = Application::builder(config).build().await?;
|
||||
app.start().await
|
||||
}
|
||||
Reference in new issue
Block a user