Refactor and clean up code across multiple modules
- Simplified token type assignment in OAuth service. - Removed unused session_lock module and re-exported Session from zesdex_entities. - Cleaned up session entity by removing unnecessary comments and code. - Consolidated session handling in HTTP handlers for better readability. - Improved formatting and readability in OAuth repository tests. - Enhanced session lock repository with clearer match statements. - Streamlined session repository error handling. - Refined RNG tests for better clarity. - Adjusted module visibility and organization in lib.rs. - Updated IPC client and connection code for better error handling and clarity. - Improved frame handling in IPC for better readability. - Organized module imports and added test utilities for IPC. - Enhanced database connection error handling. - Simplified JWT token creation error handling. - Improved password verification error handling. - Cleaned up state management code for better readability. - Refactored middleware for session authentication and rate limiting. - Simplified clipboard utility for better error handling. - Enhanced logging initialization for better error reporting. - Improved pagination utility with clearer method annotations. - Cleaned up sanitization functions for filenames and paths. - Enhanced slug generation functions for better clarity and usability.
This commit is contained in:
@@ -23,15 +23,15 @@ use uuid::Uuid;
|
||||
use zesdex_cms::domain::app_config::ProviderConfig;
|
||||
use zesdex_cms::domain::conversation::Conversation;
|
||||
use zesdex_cms::domain::memory::Memory;
|
||||
use zesdex_cms::domain::repository::{
|
||||
AppConfigRepository, ConversationRepository, MemoryRepository, SettingsRepository,
|
||||
};
|
||||
use zesdex_cms::domain::settings::Settings;
|
||||
use zesdex_cms::infrastructure::persistence::{
|
||||
JsonAppConfigRepository, JsonConversationRepository, JsonSettingsRepository,
|
||||
MarkdownMemoryRepository,
|
||||
};
|
||||
use zesdex_entities::seaorm::common::store::Store;
|
||||
use zesdex_cms::domain::repository::{
|
||||
AppConfigRepository, ConversationRepository, MemoryRepository, SettingsRepository,
|
||||
};
|
||||
use zesdex_iam::domain::repository::SessionRepository;
|
||||
use zesdex_iam::domain::session::Session;
|
||||
use zesdex_iam::infrastructure::persistence::session_repo::FileSystemSessionRepository;
|
||||
@@ -213,14 +213,12 @@ impl CmsServiceProvider for DefaultCmsServiceProvider {
|
||||
|
||||
fn save_conversation(&self, conv: &Conversation) -> Result<()> {
|
||||
let dir = self.session_dir(&conv.session_id);
|
||||
self.conversation_repo
|
||||
.save(&dir, conv)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"failed to save conversation for session '{}'",
|
||||
conv.session_id
|
||||
)
|
||||
})
|
||||
self.conversation_repo.save(&dir, conv).with_context(|| {
|
||||
format!(
|
||||
"failed to save conversation for session '{}'",
|
||||
conv.session_id
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// -- Memories --
|
||||
@@ -299,17 +297,14 @@ pub fn initialize_app_context() -> Result<AppContext> {
|
||||
.to_str()
|
||||
.ok_or_else(|| anyhow::anyhow!("invalid db path: {}", db_path.display()))?;
|
||||
|
||||
let db = database::init_db(db_path_str)
|
||||
.context("failed to initialise database")?;
|
||||
let db = database::init_db(db_path_str).context("failed to initialise database")?;
|
||||
|
||||
database::run_migrations(&db)
|
||||
.context("failed to run database migrations")?;
|
||||
database::run_migrations(&db).context("failed to run database migrations")?;
|
||||
|
||||
// -- Services --
|
||||
let iam_service: Box<dyn IamServiceProvider> =
|
||||
Box::new(DefaultIamServiceProvider::new(store.base_dir.clone()));
|
||||
let cms_service: Box<dyn CmsServiceProvider> =
|
||||
Box::new(DefaultCmsServiceProvider::new(&store));
|
||||
let cms_service: Box<dyn CmsServiceProvider> = Box::new(DefaultCmsServiceProvider::new(&store));
|
||||
|
||||
// -- JWT secret --
|
||||
let jwt_secret = std::env::var("ZESDEX_JWT_SECRET")
|
||||
|
||||
Reference in New Issue
Block a user