From 73668d79b57feb310f87141894c61ce0670cc0bc Mon Sep 17 00:00:00 2001 From: svelovla Date: Thu, 23 Oct 2014 09:50:23 +0200 Subject: [PATCH] #12 added featureDb which recieves events feature-events and should update projection --- unleash-server/lib/db.js | 1 - unleash-server/lib/featureApi.js | 5 +++-- unleash-server/lib/featureDb.js | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 unleash-server/lib/featureDb.js diff --git a/unleash-server/lib/db.js b/unleash-server/lib/db.js index 3b753a6fa0..37a9fd166b 100644 --- a/unleash-server/lib/db.js +++ b/unleash-server/lib/db.js @@ -1,6 +1,5 @@ var Promise = require('bluebird'); var featuresMock = require('./featuresMock'); -// var dbPool = require('./dbPool'); function getFeature(name) { var featureFound; diff --git a/unleash-server/lib/featureApi.js b/unleash-server/lib/featureApi.js index aaee9fa2d5..5a80b2d6e5 100644 --- a/unleash-server/lib/featureApi.js +++ b/unleash-server/lib/featureApi.js @@ -1,11 +1,12 @@ var db = require('./db'), eventStore = require('./eventStore'), - eventType = require('./eventType'); + eventType = require('./eventType'), + featureDb = require('./featureDb'); module.exports = function (app) { app.get('/features', function (req, res) { - db.getFeatures().then(function (features) { + featureDb.getFeatures().then(function (features) { res.json({features: features}); }); }); diff --git a/unleash-server/lib/featureDb.js b/unleash-server/lib/featureDb.js new file mode 100644 index 0000000000..08d960da46 --- /dev/null +++ b/unleash-server/lib/featureDb.js @@ -0,0 +1,18 @@ +var eventStore = require('./eventStore'), + eventType = require('./eventType'), + featuresMock = require('./featuresMock'), + Promise = require('bluebird'); + +eventStore.on(eventType.featureCreated, function (event) { + console.log('feature created event recieved', event); + } +); + +function getFeatures() { + return Promise.resolve(featuresMock); +} + +module.exports = { + getFeatures: getFeatures +}; +