2016-11-05 17:02:46 +01:00
|
|
|
'use strict';
|
|
|
|
|
2016-12-13 13:59:52 +01:00
|
|
|
const NotFoundError = require('../../../../lib/error/notfound-error');
|
2016-11-05 17:02:46 +01:00
|
|
|
|
|
|
|
|
2016-11-13 15:41:35 +01:00
|
|
|
|
|
|
|
module.exports = () => {
|
|
|
|
const _strategies = [{ name: 'default', parameters: {} }];
|
|
|
|
|
|
|
|
return {
|
|
|
|
getStrategies: () => Promise.resolve(_strategies),
|
2016-12-13 13:59:52 +01:00
|
|
|
getStrategy: (name) => {
|
|
|
|
const strategy = _strategies.find(s => s.name === name);
|
|
|
|
if (strategy) {
|
|
|
|
return Promise.resolve(strategy);
|
|
|
|
} else {
|
|
|
|
return Promise.reject(new NotFoundError('Not found!'));
|
|
|
|
}
|
|
|
|
},
|
2016-11-13 15:41:35 +01:00
|
|
|
addStrategy: (strat) => _strategies.push(strat),
|
|
|
|
};
|
2016-11-05 17:02:46 +01:00
|
|
|
};
|