1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/public/js/stores/FeatureToggleServerFacade.js

99 lines
2.3 KiB
JavaScript
Raw Normal View History

var reqwest = require('reqwest');
var TYPE = 'json';
var CONTENT_TYPE = 'application/json';
var FeatureToggleServerFacade = {
updateFeature: function (feature, cb) {
reqwest({
url: 'features/' + feature.name,
method: 'put',
type: TYPE,
contentType: CONTENT_TYPE,
data: JSON.stringify(feature),
error: function(error) {
cb(error);
},
success: function() {
cb();
}
});
},
createFeature: function (feature, cb) {
reqwest({
url: 'features',
method: 'post',
type: TYPE,
contentType: CONTENT_TYPE,
data: JSON.stringify(feature),
error: function(error) {
cb(error);
},
success: function() {
cb();
}
});
},
archiveFeature: function(feature, cb) {
reqwest({
url: 'features/' + feature.name,
method: 'delete',
type: TYPE,
error: function(error) {
cb(error);
},
success: function() {
cb();
}
});
},
getFeatures: function(cb) {
reqwest({
url: 'features',
method: 'get',
type: TYPE,
error: function(error) {
cb(error);
},
success: function(data) {
cb(null, data.features);
}
});
},
getArchivedFeatures: function(cb) {
reqwest({
url: 'archive/features',
method: 'get',
type: TYPE,
error: function(error) {
cb(error);
},
success: function(data) {
cb(null, data.features);
}
});
},
reviveFeature: function (feature, cb) {
reqwest({
url: 'archive/revive',
method: 'post',
type: TYPE,
contentType: CONTENT_TYPE,
data: JSON.stringify(feature),
error: function(error) {
cb(error);
},
success: function() {
cb();
}
});
}
};
module.exports = FeatureToggleServerFacade;