2021-05-09 14:17:24 -06:00
|
|
|
#![forbid(unsafe_code)]
|
|
|
|
|
2021-04-20 10:07:11 -06:00
|
|
|
use std::net::IpAddr;
|
|
|
|
|
|
|
|
use eyre::Result;
|
|
|
|
|
|
|
|
use crate::settings::Settings;
|
|
|
|
|
2021-04-20 14:53:07 -06:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
|
|
|
|
2021-04-20 10:07:11 -06:00
|
|
|
pub mod auth;
|
|
|
|
pub mod database;
|
|
|
|
pub mod handlers;
|
|
|
|
pub mod models;
|
|
|
|
pub mod router;
|
2021-04-20 14:53:07 -06:00
|
|
|
pub mod settings;
|
2021-04-20 10:07:11 -06:00
|
|
|
|
|
|
|
pub async fn launch(settings: &Settings, host: String, port: u16) -> Result<()> {
|
|
|
|
// routes to run:
|
|
|
|
// index, register, add_history, login, get_user, sync_count, sync_list
|
|
|
|
let host = host.parse::<IpAddr>()?;
|
|
|
|
|
|
|
|
let r = router::router(settings).await?;
|
|
|
|
|
|
|
|
warp::serve(r).run((host, port)).await;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|