Create state structs
This commit is contained in:
parent
5772c26537
commit
13e5a6e18c
1 changed files with 15 additions and 1 deletions
16
src/main.rs
16
src/main.rs
|
@ -25,11 +25,14 @@ mod db;
|
|||
mod secrets;
|
||||
mod server;
|
||||
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use auth::{ServerPadlockGenerator, UserAuthenticator, UserServerKeyGenerator};
|
||||
use clap::Parser;
|
||||
use color_eyre::Result;
|
||||
use config::Config;
|
||||
use db::SqliteDatabase;
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::{event, instrument, Level};
|
||||
use tracing_error::ErrorLayer;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
||||
|
@ -77,6 +80,17 @@ async fn main() -> Result<()> {
|
|||
|
||||
let config = load_config(&args.config).await?;
|
||||
|
||||
let database = Arc::new(Mutex::new(
|
||||
SqliteDatabase::open(&config.database.connection_string).await,
|
||||
));
|
||||
|
||||
let user_authenticator = Arc::new(UserAuthenticator::new(database));
|
||||
let padlock_generator = Arc::new(ServerPadlockGenerator::new(config.padlock_secret));
|
||||
let user_server_key_generator = Arc::new(UserServerKeyGenerator::new(
|
||||
Arc::clone(&user_authenticator),
|
||||
Arc::clone(&padlock_generator),
|
||||
));
|
||||
|
||||
tokio::spawn(server::run(config.port)).await??;
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue