Refactor and enhance SurrealDB integration and resource management
- Updated `lib.rs` to selectively expose specific entities and services for better clarity. - Improved SurrealDB client initialization with detailed logging in `surrealdb/mod.rs`. - Enhanced resource definitions in `resource.rs` with additional utility methods for better resource management. - Refactored user data retrieval logic in `auth_middleware/mod.rs` for improved readability and efficiency. - Cleaned up middleware exports in `lib.rs` for clearer API surface. - Added detailed comments and documentation throughout the SurrealDB module for better maintainability. - Updated tests to ensure compatibility with new changes and improved structure. - Introduced new permissions module structure in `imphnen-utils` for future enhancements.
This commit is contained in:
+5
-4
@@ -1,7 +1,8 @@
|
||||
use ::surrealdb::Uuid;
|
||||
use ::surrealdb::sql;
|
||||
pub use imphnen_entities::*;
|
||||
pub use imphnen_iam::*;
|
||||
pub use imphnen_entities::MetaRequestDto;
|
||||
pub use imphnen_iam::{ResourceEnum, RolesRepository, UsersRepository, AuthOtpSchema, AuthRepository, RolesDetailQueryDto, UsersDetailQueryDto, RolesRequestCreateDto, RolesRequestUpdateDto, RolesDetailItemDto, TeamsRepository, TeamsSchema, TeamMembersSchema, TeamInvitationsSchema, UsersSchema};
|
||||
use imphnen_libs::AppState;
|
||||
|
||||
pub fn create_test_mentor(
|
||||
email: &str,
|
||||
@@ -69,7 +70,7 @@ pub fn generate_unique_email(prefix: &str) -> String {
|
||||
format!("{}_{}@example.com", prefix, Uuid::new_v4())
|
||||
}
|
||||
|
||||
pub async fn get_role_id(role_name: &str, state: &crate::AppState) -> sql::Thing {
|
||||
pub async fn get_role_id(role_name: &str, state: &AppState) -> sql::Thing {
|
||||
let repo = RolesRepository::new(state);
|
||||
if let Ok(existing) = repo.query_role_by_name(role_name.into()).await {
|
||||
return make_thing(&ResourceEnum::Roles.to_string(), &existing.id);
|
||||
@@ -87,7 +88,7 @@ pub async fn get_role_id(role_name: &str, state: &crate::AppState) -> sql::Thing
|
||||
make_thing(&ResourceEnum::Roles.to_string(), &role.id)
|
||||
}
|
||||
|
||||
pub async fn get_app_state() -> crate::AppState {
|
||||
pub async fn get_app_state() -> AppState {
|
||||
create_mock_app_state().await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user