mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-23 20:07:40 +02:00
This simplifies stores to just be storage interaction, they no longer react to events. Controllers now call services and awaits the result from the call. When the service calls are returned the database is updated. This simplifies testing dramatically, cause you know that your state is updated when returned from a call, rather than hoping the store has picked up the event (which really was a command) and reacted to it. Events are still emitted from eventStore, so other parts of the app can react to events as they're being sent out. As part of the move to services, we now also emit an application-created event when we see a new client application. Fixes: #685 Fixes: #595
30 lines
784 B
JavaScript
30 lines
784 B
JavaScript
'use strict';
|
|
|
|
const NotFoundError = require('../../lib/error/notfound-error');
|
|
|
|
module.exports = () => {
|
|
let apps = [];
|
|
|
|
return {
|
|
upsert: app => {
|
|
apps.push(app);
|
|
return Promise.resolve();
|
|
},
|
|
insertNewRow: value => {
|
|
apps.push(value);
|
|
return Promise.resolve();
|
|
},
|
|
getApplications: () => Promise.resolve(apps),
|
|
getApplication: appName => {
|
|
const app = apps.filter(a => a.appName === appName)[0];
|
|
if (!app) {
|
|
throw new NotFoundError(`Could not find app=${appName}`);
|
|
}
|
|
return app;
|
|
},
|
|
deleteApplication: appName => {
|
|
apps = apps.filter(app => app.appName !== appName);
|
|
},
|
|
};
|
|
};
|