Adding get by unique ID to core
Our core can now support the getting of the user using the unique ID with the following code:
// nanoservices/auth/core/src/api/users/get.rs
use auth_dal::users::schema::TrimmedUser;
use auth_dal::users::transactions::get::GetByUniqueId;
use glue::errors::NanoServiceError;
pub async fn get_by_unique_id<T: GetByUniqueId>(id: String)
-> Result<TrimmedUser, NanoServiceError> {
let user = T::get_by_unique_id(id).await?;
let trimmed_user: TrimmedUser = user.into();
Ok(trimmed_user)
}
And again, we must ensure that our function must be made accessible with the code below:
// nanoservices/auth/core/src/api/users/mod.rs
pub mod create;
pub mod get;
Now our endpoint is ready to be exposed to the world in our networking layer.