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
feat: add user added topic
  • Loading branch information
yoution committed Jul 26, 2021
commit 1c7d754d3780fdf9301c34949da3c5e9a054f1ce
1 change: 1 addition & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ 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_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
8 changes: 7 additions & 1 deletion src/modules/user/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

const joi = require('@hapi/joi')
const _ = require('lodash')
const config = require('config')

const errors = require('../../common/errors')
const logger = require('../../common/logger')
const helper = require('../../common/helper')
const dbHelper = require('../../common/db-helper')
const serviceHelper = require('../../common/service-helper')
Expand Down Expand Up @@ -33,7 +35,11 @@ async function create (entity, auth) {
const result = await sequelize.transaction(async (t) => {
const userEntity = await dbHelper.create(User, entity, auth, t)
await serviceHelper.createRecordInEs(resource, userEntity.dataValues, true)
return userEntity
try {
await helper.postEvent(config.UBAHN_CREATE_USER_TOPIC, userEntity.dataValues)
} catch (err) {
logger.logFullError(err)
}
})

return result
Expand Down