2016-11-05 17:02:46 +01:00
|
|
|
'use strict';
|
|
|
|
|
2017-06-28 10:20:22 +02:00
|
|
|
const NotFoundError = require('../../lib/error/notfound-error');
|
2016-11-13 15:41:35 +01:00
|
|
|
|
|
|
|
module.exports = () => {
|
2017-06-29 08:42:03 +02:00
|
|
|
const _strategies = [{ name: 'default', editable: false, parameters: {} }];
|
2016-11-13 15:41:35 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
getStrategies: () => Promise.resolve(_strategies),
|
2019-03-14 17:56:02 +01:00
|
|
|
getEditableStrategies: () =>
|
|
|
|
Promise.resolve(_strategies.filter(s => s.editable)),
|
2017-06-28 10:20:22 +02:00
|
|
|
getStrategy: name => {
|
2016-12-13 13:59:52 +01:00
|
|
|
const strategy = _strategies.find(s => s.name === name);
|
|
|
|
if (strategy) {
|
|
|
|
return Promise.resolve(strategy);
|
|
|
|
}
|
2020-04-14 22:29:11 +02:00
|
|
|
return Promise.reject(new NotFoundError('Not found!'));
|
2016-12-13 13:59:52 +01:00
|
|
|
},
|
2017-06-28 10:20:22 +02:00
|
|
|
addStrategy: strat => _strategies.push(strat),
|
2016-11-13 15:41:35 +01:00
|
|
|
};
|
2016-11-05 17:02:46 +01:00
|
|
|
};
|