Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Shapeup4 - CQRS standards update (user object) #103

Merged
merged 21 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: add update and delete topic for user
  • Loading branch information
yoution committed Jul 27, 2021
commit 34b6cbd814512eda5bcf4a4319a9afff28cd1fb0
4 changes: 3 additions & 1 deletion config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ module.exports = {
KAFKA_MESSAGE_ORIGINATOR: process.env.KAFKA_MESSAGE_ORIGINATOR || 'u-bahn-api',

// topics
UBAHN_CREATE_USER_TOPIC: process.env.UBAHN_CREATE_TOPIC || 'user.action.topic.create',
UBAHN_CREATE_USER_TOPIC: process.env.UBAHN_CREATE_USER_TOPIC || 'user.action.topic.create',
UBAHN_UPDATE_USER_TOPIC: process.env.UBAHN_UPDATE_USER_TOPIC || 'user.action.topic.update',
UBAHN_DELETE_USER_TOPIC: process.env.UBAHN_DELETE_USER_TOPIC || 'user.action.topic.delete',
UBAHN_CREATE_TOPIC: process.env.UBAHN_CREATE_TOPIC || 'u-bahn.action.create',
UBAHN_UPDATE_TOPIC: process.env.UBAHN_UPDATE_TOPIC || 'u-bahn.action.update',
UBAHN_DELETE_TOPIC: process.env.UBAHN_DELETE_TOPIC || 'u-bahn.action.delete',
Expand Down
11 changes: 11 additions & 0 deletions src/modules/user/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ async function patch (id, entity, auth, params) {
const result = await sequelize.transaction(async (t) => {
const newEntity = await dbHelper.update(User, id, entity, auth, null, t)
await serviceHelper.patchRecordInEs(resource, newEntity.dataValues, true)

try {
await helper.postEvent(config.UBAHN_UPDATE_USER_TOPIC, newEntity.dataValues)
} catch (err) {
logger.logFullError(err)
}
return newEntity
})

Expand Down Expand Up @@ -182,6 +188,11 @@ async function beginCascadeDelete (id, params) {
await serviceHelper.deleteChild(UsersSkill, id, ['userId', 'skillId'], 'UsersSkill', t)
await dbHelper.remove(User, id, null, t)
await serviceHelper.deleteRecordFromEs(id, params, resource, true)
try {
await helper.postEvent(config.UBAHN_DELETE_USER_TOPIC, {id})
} catch (err) {
logger.logFullError(err)
}
})
}

Expand Down