Refactor (#4)

Reviewed-on: #4
This commit is contained in:
2025-12-26 00:32:20 +00:00
parent 58de25e5bc
commit 1bacb454fa
11 changed files with 238 additions and 115 deletions

View File

@@ -82,20 +82,7 @@ pub async fn create_note(
let note = state.note_service.create_note(domain_req).await?;
// Publish event
#[cfg(feature = "smart-features")]
{
let payload = serde_json::to_vec(&note).unwrap_or_default();
if let Err(e) = state
.nats_client
.publish("notes.updated", payload.into())
.await
{
tracing::error!("Failed to publish notes.updated event: {}", e);
} else {
tracing::info!("Published notes.updated event for note {}", note.id);
}
}
// Event publishing is now handled in NoteService via MessageBroker
Ok((StatusCode::CREATED, Json(NoteResponse::from(note))))
}
@@ -152,20 +139,7 @@ pub async fn update_note(
let note = state.note_service.update_note(domain_req).await?;
// Publish event
#[cfg(feature = "smart-features")]
{
let payload = serde_json::to_vec(&note).unwrap_or_default();
if let Err(e) = state
.nats_client
.publish("notes.updated", payload.into())
.await
{
tracing::error!("Failed to publish notes.updated event: {}", e);
} else {
tracing::info!("Published notes.updated event for note {}", note.id);
}
}
// Event publishing is now handled in NoteService via MessageBroker
Ok(Json(NoteResponse::from(note)))
}