/* This file is part of jellything (https://codeberg.org/metamuffin/jellything) which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin */ #![feature(int_roundings, let_chains)] #![allow(clippy::needless_borrows_for_generic_args)] use crate::routes::ui::{account::hash_password, admin::log::enable_logging}; use anyhow::Context; use database::Database; use jellybase::{federation::Federation, CONF, SECRETS}; use log::{error, info, warn}; use routes::build_rocket; use tokio::fs::create_dir_all; pub use jellybase::database; pub mod routes; #[rocket::main] async fn main() { enable_logging(); #[cfg(feature = "bypass-auth")] log::warn!("authentification bypass enabled"); create_dir_all(&CONF.cache_path).await.unwrap(); let database = Database::open(&CONF.database_path) .context("opening database") .unwrap(); let federation = Federation::initialize(); if let Some(username) = &CONF.admin_username && let Some(password) = &SECRETS.admin_password { database .create_admin_user(username, hash_password(username, password)) .unwrap(); } else { info!("admin account disabled") } let r = build_rocket(database, federation).launch().await; match r { Ok(_) => warn!("server shutdown"), Err(e) => error!("server exited: {e}"), } }