Creation
This commit is contained in:
parent
5149a2d7d1
commit
8a93f91e69
19 changed files with 7090 additions and 1 deletions
44
src/main.rs
Normal file
44
src/main.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
mod data;
|
||||
mod server;
|
||||
mod sql;
|
||||
mod util;
|
||||
|
||||
use crate::sql::sql::initialize_db;
|
||||
use crate::sql::sql::print_users;
|
||||
use crate::util::crypto_helper::load_public_key;
|
||||
use crate::util::crypto_helper::load_secret_key;
|
||||
use crate::util::logger::startup;
|
||||
use dotenv::dotenv;
|
||||
use once_cell::sync::Lazy;
|
||||
use std::env;
|
||||
|
||||
static PRIVATE_KEY: Lazy<String> = Lazy::new(|| env::var("PRIVATE_KEY").unwrap());
|
||||
pub fn get_private_key() -> x448::Secret {
|
||||
load_secret_key(&*PRIVATE_KEY).unwrap()
|
||||
}
|
||||
static PUBLIC_KEY: Lazy<String> = Lazy::new(|| env::var("PUBLIC_KEY").unwrap());
|
||||
pub fn get_public_key() -> x448::PublicKey {
|
||||
load_public_key(&*PUBLIC_KEY).unwrap()
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
dotenv().ok();
|
||||
startup();
|
||||
log!("Started");
|
||||
log_in!("Incoming messages");
|
||||
log_out!("Outgoing messages");
|
||||
log!(" .env");
|
||||
if let Err(e) = initialize_db().await {
|
||||
log!("[FATAL] Database initialization failed: {}", e);
|
||||
log!(
|
||||
"[FATAL] Please ensure the database is running and the .env file is configured correctly."
|
||||
);
|
||||
return;
|
||||
}
|
||||
let _ = print_users().await;
|
||||
log!(" DB");
|
||||
server::server::start(9187).await;
|
||||
log!(" Server");
|
||||
loop {}
|
||||
}
|
||||
Loading…
Reference in a new issue