mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
a96a9f38ce
* #108 Add eslint-config-spt * #108 Ignore bundle.js file * #108 Change eslint ignore path to a glob file * Remove jshint and follow more of eslint rules
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
var reqwest = require('reqwest');
|
|
|
|
var TYPE = 'json';
|
|
var CONTENT_TYPE = 'application/json';
|
|
|
|
var StrategyAPI = {
|
|
createStrategy: function (strategy, cb) {
|
|
reqwest({
|
|
url: 'strategies',
|
|
method: 'post',
|
|
type: TYPE,
|
|
contentType: CONTENT_TYPE,
|
|
data: JSON.stringify(strategy),
|
|
error: function(error) {
|
|
cb(error);
|
|
},
|
|
success: function() {
|
|
cb(null, strategy);
|
|
}
|
|
});
|
|
},
|
|
|
|
removeStrategy: function (strategy, cb) {
|
|
reqwest({
|
|
url: 'strategies/'+strategy.name,
|
|
method: 'delete',
|
|
type: TYPE,
|
|
error: function(error) {
|
|
cb(error);
|
|
},
|
|
success: function() {
|
|
cb(null, strategy);
|
|
}
|
|
});
|
|
},
|
|
|
|
getStrategies: function (cb) {
|
|
reqwest({
|
|
url: 'strategies',
|
|
method: 'get',
|
|
type: TYPE,
|
|
error: function(error) {
|
|
cb(error);
|
|
},
|
|
success: function(data) {
|
|
cb(null, data.strategies);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = StrategyAPI;
|