mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-01 01:18:10 +02:00
Fixed failing validations
This commit is contained in:
parent
2244fd6c2e
commit
247d342be9
@ -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.
|
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`.
|
4. Run `npm run db-migrate-up`.
|
||||||
5. Generate LB artifact using `scripts/generate-liquibase-artifact` (TODO: make this internal)
|
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'),
|
var Promise = require('bluebird'),
|
||||||
util = require('util'),
|
util = require('util'),
|
||||||
dbPool = require('./dbPool'),
|
|
||||||
EventEmitter = require('events').EventEmitter;
|
EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
function EventStore() {
|
function EventStore() {
|
||||||
@ -8,15 +7,7 @@ function EventStore() {
|
|||||||
}
|
}
|
||||||
util.inherits(EventStore, EventEmitter);
|
util.inherits(EventStore, EventEmitter);
|
||||||
|
|
||||||
EventStore.prototype.create = function (eventType, user, eventData) {
|
EventStore.prototype.create = function (event) {
|
||||||
var event = {
|
|
||||||
id: 1,
|
|
||||||
created: '2014-08-01 12:22:00',
|
|
||||||
type: eventType,
|
|
||||||
user: user,
|
|
||||||
data: eventData
|
|
||||||
};
|
|
||||||
|
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
this.emit(event.type, event);
|
this.emit(event.type, event);
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -30,7 +30,11 @@ module.exports = function (app) {
|
|||||||
//Todo: error-msg: feature name is already in use
|
//Todo: error-msg: feature name is already in use
|
||||||
res.status(403).end();
|
res.status(403).end();
|
||||||
} else {
|
} else {
|
||||||
eventStore.create(eventType.featureCreated, user, newFeature).then(function() {
|
eventStore.create({
|
||||||
|
type: eventType.featureCreated,
|
||||||
|
user: user,
|
||||||
|
data: newFeature
|
||||||
|
}).then(function() {
|
||||||
res.status(201).end();
|
res.status(201).end();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,11 @@ describe('EventStore', function () {
|
|||||||
'description': 'Feature description'
|
'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