mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
23 lines
723 B
JavaScript
23 lines
723 B
JavaScript
'use strict';
|
|
|
|
const NotFoundError = require('../../lib/error/notfound-error');
|
|
|
|
module.exports = () => {
|
|
const _strategies = [{ name: 'default', editable: false, parameters: {} }];
|
|
|
|
return {
|
|
getStrategies: () => Promise.resolve(_strategies),
|
|
getEditableStrategies: () =>
|
|
Promise.resolve(_strategies.filter(s => s.editable)),
|
|
getStrategy: name => {
|
|
const strategy = _strategies.find(s => s.name === name);
|
|
if (strategy) {
|
|
return Promise.resolve(strategy);
|
|
} else {
|
|
return Promise.reject(new NotFoundError('Not found!'));
|
|
}
|
|
},
|
|
addStrategy: strat => _strategies.push(strat),
|
|
};
|
|
};
|