blob: 6634143eec30249172a7cf14c915362a227def94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*
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 <metamuffin.org>
*/
#![feature(int_roundings, let_chains, str_as_str)]
#![allow(clippy::needless_borrows_for_generic_args)]
#![recursion_limit = "4096"]
use anyhow::Context;
use database::Database;
use jellybase::{federation::Federation, CONF, SECRETS};
use jellylogic::admin::log::enable_logging;
use log::{error, info, warn};
use routes::build_rocket;
use tokio::fs::create_dir_all;
use ui::account::hash_password;
pub use jellybase::database;
pub mod api;
pub mod compat;
pub mod helper;
pub mod locale;
pub mod logic;
pub mod routes;
pub mod ui;
#[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}"),
}
}
|