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
pub mod config;
pub mod error;
pub mod model;
pub mod module;
pub mod service;
pub mod utils;
pub mod web;

use crate::error::LsError;
use crate::service::auth::InMemoryRolesProvider;
use log::info;
use std::sync::Arc;

#[derive(Clone)]
pub struct LsCoreModule {
    pub auth: Arc<service::auth::LsAuthService>,
    pub jwt: Arc<service::jwt::LsJwtService>,
}

impl LsCoreModule {
    pub fn new(config: config::CoreConfig) -> Result<LsCoreModule, LsError> {
        println!("Creating LsCoreModule");
        info!("Creating LsCoreModule");

        let jwt = Arc::new(service::jwt::LsJwtService::new(&config.jwt)?);
        let auth = Arc::new(service::auth::LsAuthService::new(InMemoryRolesProvider::new(vec![].into())));
        Ok(LsCoreModule { jwt, auth })
    }
}

impl module::LsModule for LsCoreModule {
    async fn start(&mut self) -> Result<(), LsError> {
        info!("Starting LsCoreModule");
        Ok(())
    }
}