f4240aa62b
This can be used in the future for sync so that we can be more intelligent with what we're doing, and only sync up what's needed I'd like to eventually replace this with something more like a merkle tree, hence the hash field I've exposed, but that can come later Although this does include a much larger number of count queries, it should also be significantly more cache-able. I'll follow up with that later, and also follow up with using this for sync :)
39 lines
805 B
Rust
39 lines
805 B
Rust
#![forbid(unsafe_code)]
|
|
|
|
use std::net::{IpAddr, SocketAddr};
|
|
|
|
use axum::Server;
|
|
use database::Postgres;
|
|
use eyre::{Context, Result};
|
|
|
|
use crate::settings::Settings;
|
|
|
|
#[macro_use]
|
|
extern crate log;
|
|
|
|
#[macro_use]
|
|
extern crate serde_derive;
|
|
|
|
pub mod auth;
|
|
pub mod calendar;
|
|
pub mod database;
|
|
pub mod handlers;
|
|
pub mod models;
|
|
pub mod router;
|
|
pub mod settings;
|
|
|
|
pub async fn launch(settings: Settings, host: String, port: u16) -> Result<()> {
|
|
let host = host.parse::<IpAddr>()?;
|
|
|
|
let postgres = Postgres::new(settings.db_uri.as_str())
|
|
.await
|
|
.wrap_err_with(|| format!("failed to connect to db: {}", settings.db_uri))?;
|
|
|
|
let r = router::router(postgres, settings);
|
|
|
|
Server::bind(&SocketAddr::new(host, port))
|
|
.serve(r.into_make_service())
|
|
.await?;
|
|
|
|
Ok(())
|
|
}
|