2014-10-24 16:15:59 +02:00
|
|
|
var Promise = require("bluebird");
|
|
|
|
|
|
|
|
var events = [
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"created_at": 1414159948677,
|
|
|
|
"type": "feature-create",
|
|
|
|
"created_by": "me",
|
|
|
|
"data": {
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": 2,
|
|
|
|
"created_at": 1414159948677,
|
|
|
|
"type": "feature-create",
|
|
|
|
"created_by": "me",
|
|
|
|
"data": {
|
|
|
|
"foo": "bar"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": 3,
|
|
|
|
"created_at": 1414159948677,
|
|
|
|
"type": "feature-create",
|
|
|
|
"created_by": "me",
|
|
|
|
"data": {
|
|
|
|
"foo": "rab"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
function getEvent(name) {
|
|
|
|
var eventFound;
|
|
|
|
events.forEach(function (event) {
|
|
|
|
if (event.name === name) {
|
|
|
|
eventFound = event;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return eventFound;
|
|
|
|
}
|
2014-10-23 12:03:46 +02:00
|
|
|
|
2014-10-23 16:02:12 +02:00
|
|
|
function storeEvent() {
|
2014-10-23 12:03:46 +02:00
|
|
|
return new Promise(function (resolve) {
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
2014-10-24 16:15:59 +02:00
|
|
|
store: storeEvent,
|
|
|
|
|
|
|
|
getEvents: function() {
|
|
|
|
return new Promise(function (resolve) {
|
|
|
|
resolve(events);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
getEvent: function(name) {
|
|
|
|
var event = getEvent(name);
|
|
|
|
if(event) {
|
|
|
|
return Promise.resolve(event);
|
|
|
|
} else {
|
|
|
|
return Promise.reject("Event not found");
|
|
|
|
}
|
|
|
|
}
|
2014-10-23 12:03:46 +02:00
|
|
|
};
|