aboutsummaryrefslogtreecommitdiff
path: root/logic/src/lib.rs
blob: 79d27d960c3fff696f984ed082181c8452539d3e (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
/*
    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(duration_constructors, let_chains)]

pub mod admin;
pub mod filter_sort;
pub mod home;
pub mod items;
pub mod login;
pub mod node;
pub mod search;
pub mod session;
pub mod stats;

pub use jellydb::Database;

use serde::{Deserialize, Serialize};
use std::sync::LazyLock;
use std::sync::Mutex;

#[rustfmt::skip]
#[derive(Debug, Deserialize, Serialize, Default)]
pub struct Config {
  login_expire: i64,
  session_key: Option<String>,
  admin_username:Option<String>,
  admin_password:Option<String>,
}

pub static CONF_PRELOAD: Mutex<Option<Config>> = Mutex::new(None);
static CONF: LazyLock<Config> = LazyLock::new(|| {
    CONF_PRELOAD
        .lock()
        .unwrap()
        .take()
        .expect("logic config not preloaded. logic error")
});