blob: 00543ceb7ec04956c58aecfcd7e871ac2423225f (
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
|
/*
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) 2023 metamuffin <metamuffin.org>
*/
#![feature(box_syntax)]
use config::{load_global_config, GlobalConfig};
use database::{Database, User};
use jellyremuxer::RemuxerContext;
use library::Library;
use once_cell::sync::Lazy;
use rocket::launch;
use routes::{build_rocket, ui::account::hash_password};
pub mod config;
pub mod database;
pub mod library;
pub mod routes;
pub static CONF: Lazy<GlobalConfig> = Lazy::new(|| load_global_config());
#[launch]
fn rocket() -> _ {
env_logger::builder()
.filter_level(log::LevelFilter::Info)
.parse_env("LOG")
.init();
#[cfg(feature = "bypass-auth")]
warn!("authentification bypass enabled");
let remuxer = RemuxerContext::new();
let library = Library::open(&CONF.library_path).unwrap();
let database = Database::open(&CONF.database_path).unwrap();
database
.users
.insert(
&CONF.admin_username,
&User {
admin: true,
display_name: "Admin".to_string(),
name: CONF.admin_username.clone(),
password: hash_password(&CONF.admin_password),
},
)
.unwrap();
build_rocket(remuxer, library, database)
}
|