HomeDisk/core/src/main.rs

34 lines
801 B
Rust
Raw Normal View History

mod init;
use homedisk_database::Database;
2022-04-19 19:10:36 +00:00
use homedisk_types::config::types::Config;
2022-04-16 18:19:38 +00:00
#[tokio::main]
async fn main() {
init::init();
2022-04-16 18:19:38 +00:00
let config = Config::parse().expect("parse configuration file");
2022-04-16 19:22:01 +00:00
let db = Database::open("homedisk.db")
.await
.expect("open SQLite database");
// change the type from Vec<String> to Vec<HeaderValue> so that the http server can correctly detect CORS hosts
let origins = config
.http
.cors
.iter()
.map(|e| e.parse().expect("parse CORS host"))
.collect();
let host = format!(
"{host}:{port}",
host = config.http.host,
port = config.http.port
);
homedisk_server::serve(host, origins, db, config)
.await
.expect("start http server");
2022-04-16 18:19:38 +00:00
}