aboutsummaryrefslogtreecommitdiff
path: root/server/src/main.rs
blob: 341f72b02c4a580cc1fa4a84d231cdfe8337de6a (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
/*
    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(lazy_cell)]

use std::fs::File;
use database::Database;
use jellycommon::config::GlobalConfig;
use jellyremuxer::RemuxerContext;
use once_cell::sync::Lazy;
use rocket::launch;
use routes::build_rocket;

pub mod database;
pub mod import;
pub mod routes;

pub static CONF: Lazy<GlobalConfig> =
    Lazy::new(|| serde_json::from_reader(File::open("data/config.json").unwrap()).unwrap());

#[launch]
fn rocket() -> _ {
    env_logger::builder()
        .filter_level(log::LevelFilter::Info)
        .parse_env("LOG")
        .init();

    #[cfg(feature = "bypass-auth")]
    log::warn!("authentification bypass enabled");

    let remuxer = RemuxerContext::new();
    let database = Database::open(&CONF.database_path).unwrap();
    import::import(&database).unwrap();
    database.create_admin();
    build_rocket(remuxer, database)
}