1
#![recursion_limit = "256"]
2

            
3
// Test-only file to reexport the modules for testing
4
#[macro_use]
5
extern crate rust_i18n;
6

            
7
i18n!("locales", fallback = "en");
8

            
9
pub mod assets;
10
pub mod auth_keys;
11
pub mod client_ip;
12
pub mod config;
13
pub mod error_render;
14
pub mod form_invalid;
15
pub mod form_render;
16
pub mod handler;
17
pub mod jwt_auth;
18
pub mod login;
19
pub mod model;
20
pub mod pages;
21
pub mod parse;
22
pub mod rate_limit;
23
pub mod register;
24
pub mod response;
25
pub mod route;
26
pub mod session;
27
pub mod telemetry;
28
pub mod token;
29

            
30
pub use config::Config;
31
pub use model::{LoginUserSchema, RegisterUserSchema, User};
32
pub use token::{TokenClaims, TokenDetails};
33

            
34
use redis::Client;
35
use std::sync::Arc;
36
use tokio::sync::Mutex;
37

            
38
pub struct AppState {
39
    pub conf: Config,
40
    pub redis_client: Client,
41
    pub user: Mutex<Option<User>>,
42
}
43

            
44
impl AppState {
45
    #[must_use]
46
541
    pub fn new(conf: Config, redis_client: Client) -> Arc<Self> {
47
541
        Arc::new(Self {
48
541
            conf,
49
541
            redis_client,
50
541
            user: Mutex::new(None),
51
541
        })
52
541
    }
53
}