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

Commit 1c7d754

Browse files
committed
feat: add user added topic
1 parent a15dd36 commit 1c7d754

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

config/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module.exports = {
3535
KAFKA_MESSAGE_ORIGINATOR: process.env.KAFKA_MESSAGE_ORIGINATOR || 'u-bahn-api',
3636

3737
// topics
38+
UBAHN_CREATE_USER_TOPIC: process.env.UBAHN_CREATE_TOPIC || 'user.action.topic.create',
3839
UBAHN_CREATE_TOPIC: process.env.UBAHN_CREATE_TOPIC || 'u-bahn.action.create',
3940
UBAHN_UPDATE_TOPIC: process.env.UBAHN_UPDATE_TOPIC || 'u-bahn.action.update',
4041
UBAHN_DELETE_TOPIC: process.env.UBAHN_DELETE_TOPIC || 'u-bahn.action.delete',

src/modules/user/service.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
const joi = require('@hapi/joi')
66
const _ = require('lodash')
7+
const config = require('config')
78

89
const errors = require('../../common/errors')
10+
const logger = require('../../common/logger')
911
const helper = require('../../common/helper')
1012
const dbHelper = require('../../common/db-helper')
1113
const serviceHelper = require('../../common/service-helper')
@@ -33,7 +35,11 @@ async function create (entity, auth) {
3335
const result = await sequelize.transaction(async (t) => {
3436
const userEntity = await dbHelper.create(User, entity, auth, t)
3537
await serviceHelper.createRecordInEs(resource, userEntity.dataValues, true)
36-
return userEntity
38+
try {
39+
await helper.postEvent(config.UBAHN_CREATE_USER_TOPIC, userEntity.dataValues)
40+
} catch (err) {
41+
logger.logFullError(err)
42+
}
3743
})
3844

3945
return result

0 commit comments

Comments
 (0)