mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
Fixed failing validations
This commit is contained in:
parent
1c0d7c5944
commit
a1b0deaba0
@ -28,3 +28,15 @@ npm test
|
||||
3. Run `db-migrate create your-migration-name` and edit the generated file to run the above SQL files.
|
||||
4. Run `npm run db-migrate-up`.
|
||||
5. Generate LB artifact using `scripts/generate-liquibase-artifact` (TODO: make this internal)
|
||||
|
||||
### Create a local unleash-db on postgres
|
||||
´´´sql
|
||||
CREATE USER unleash_user WITH PASSWORD 'passord';
|
||||
CREATE DATABASE unleash;
|
||||
GRANT ALL PRIVILEGES ON DATABASE unleash to unleash_user;
|
||||
´´´
|
||||
|
||||
Then set up your DATABASE_URI env.var:
|
||||
```
|
||||
export DATABASE_URL=postgres://unleash_user:passord@localhost:5432/unleash
|
||||
```
|
||||
|
19
unleash-server/lib/eventDb.js
Normal file
19
unleash-server/lib/eventDb.js
Normal file
@ -0,0 +1,19 @@
|
||||
var Promise = require('bluebird'),
|
||||
dbPool = require('./dbPool');
|
||||
|
||||
function storeEvent(event) {
|
||||
var sql = 'INSERT INTO events(type, user, data) VALUES ($1, $2, $3)';
|
||||
var params = [event.type,event.user,event.data];
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
dbPool.query(sql, params, function (err) {
|
||||
if (err) {reject(err);}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
store: storeEvent()
|
||||
};
|
@ -1,6 +1,5 @@
|
||||
var Promise = require('bluebird'),
|
||||
util = require('util'),
|
||||
dbPool = require('./dbPool'),
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
function EventStore() {
|
||||
@ -8,15 +7,7 @@ function EventStore() {
|
||||
}
|
||||
util.inherits(EventStore, EventEmitter);
|
||||
|
||||
EventStore.prototype.create = function (eventType, user, eventData) {
|
||||
var event = {
|
||||
id: 1,
|
||||
created: '2014-08-01 12:22:00',
|
||||
type: eventType,
|
||||
user: user,
|
||||
data: eventData
|
||||
};
|
||||
|
||||
EventStore.prototype.create = function (event) {
|
||||
return new Promise(function (resolve) {
|
||||
this.emit(event.type, event);
|
||||
resolve();
|
||||
|
@ -30,7 +30,11 @@ module.exports = function (app) {
|
||||
//Todo: error-msg: feature name is already in use
|
||||
res.status(403).end();
|
||||
} else {
|
||||
eventStore.create(eventType.featureCreated, user, newFeature).then(function() {
|
||||
eventStore.create({
|
||||
type: eventType.featureCreated,
|
||||
user: user,
|
||||
data: newFeature
|
||||
}).then(function() {
|
||||
res.status(201).end();
|
||||
});
|
||||
}
|
||||
|
@ -18,7 +18,11 @@ describe('EventStore', function () {
|
||||
'description': 'Feature description'
|
||||
};
|
||||
|
||||
eventStore.create(eventType.featureCreated,'ole',eventData);
|
||||
eventStore.create({
|
||||
type: eventType.featureCreated,
|
||||
user: 'ole',
|
||||
data: eventData
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user