Skip to main content

web/
lib.rs

1// Test-only file to reexport the modules for testing
2#[macro_use]
3extern crate rust_i18n;
4
5i18n!("locales", fallback = "en");
6
7pub mod config;
8pub mod files;
9pub mod handler;
10pub mod jwt_auth;
11pub mod model;
12pub mod pages;
13pub mod redirect_middleware;
14pub mod response;
15pub mod route;
16pub mod token;
17
18pub use config::Config;
19pub use model::{LoginUserSchema, RegisterUserSchema, User};
20pub use token::{TokenClaims, TokenDetails};
21
22use redis::Client;
23use std::sync::Arc;
24use tokio::sync::Mutex;
25
26pub struct AppState {
27    pub conf: Config,
28    pub redis_client: Client,
29    pub frac: i64,
30    pub user: Mutex<Option<User>>,
31}
32
33impl AppState {
34    #[must_use]
35    pub fn new(conf: Config, redis_client: Client) -> Arc<Self> {
36        Arc::new(Self {
37            conf,
38            redis_client,
39            frac: 0,
40            user: Mutex::new(None),
41        })
42    }
43}