diff --git a/unleash-server/lib/eventStore.js b/unleash-server/lib/eventStore.js index d099936f69..3c531d60cc 100644 --- a/unleash-server/lib/eventStore.js +++ b/unleash-server/lib/eventStore.js @@ -1,10 +1,10 @@ -var util = require('util'); -var EventEmitter = require('events').EventEmitter; +var Promise = require('bluebird'), + util = require('util'), + EventEmitter = require('events').EventEmitter; function EventStore() { EventEmitter.call(this); } - util.inherits(EventStore, EventEmitter); EventStore.prototype.create = function (eventType, user, eventData) { @@ -16,7 +16,10 @@ EventStore.prototype.create = function (eventType, user, eventData) { data: eventData }; - this.emit(event.type, event); + return new Promise(function (resolve, reject) { + this.emit(event.type, event); + resolve(); + }.bind(this)); }; module.exports = new EventStore(); \ No newline at end of file diff --git a/unleash-server/lib/featureApi.js b/unleash-server/lib/featureApi.js index 83eb5a4f85..9d501a23f9 100644 --- a/unleash-server/lib/featureApi.js +++ b/unleash-server/lib/featureApi.js @@ -29,8 +29,9 @@ module.exports = function (app) { //Todo: error-msg: feature name is already in use res.status(403).end(); } else { - eventStore.create(eventType.featureCreated, user, newFeature); - res.status(201).end(); + eventStore.create(eventType.featureCreated, user, newFeature).then(function() { + res.status(201).end(); + }); } }); });