2016-12-06 09:27:32 +01:00
|
|
|
'use strict';
|
|
|
|
|
2021-01-18 12:32:19 +01:00
|
|
|
const NotFoundError = require('../../lib/error/notfound-error');
|
|
|
|
|
2018-11-29 21:45:26 +01:00
|
|
|
module.exports = () => {
|
2020-09-25 09:39:12 +02:00
|
|
|
let apps = [];
|
2018-01-17 15:31:53 +01:00
|
|
|
|
2018-11-29 21:45:26 +01:00
|
|
|
return {
|
|
|
|
upsert: app => {
|
|
|
|
apps.push(app);
|
|
|
|
return Promise.resolve();
|
|
|
|
},
|
2021-01-18 12:32:19 +01:00
|
|
|
insertNewRow: value => {
|
|
|
|
apps.push(value);
|
|
|
|
return Promise.resolve();
|
|
|
|
},
|
2018-11-29 21:45:26 +01:00
|
|
|
getApplications: () => Promise.resolve(apps),
|
2020-09-25 09:39:12 +02:00
|
|
|
getApplication: appName => {
|
|
|
|
const app = apps.filter(a => a.appName === appName)[0];
|
|
|
|
if (!app) {
|
2021-01-18 12:32:19 +01:00
|
|
|
throw new NotFoundError(`Could not find app=${appName}`);
|
2020-09-25 09:39:12 +02:00
|
|
|
}
|
|
|
|
return app;
|
|
|
|
},
|
|
|
|
deleteApplication: appName => {
|
|
|
|
apps = apps.filter(app => app.appName !== appName);
|
|
|
|
},
|
2018-11-29 21:45:26 +01:00
|
|
|
};
|
|
|
|
};
|