1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/packages/unleash-frontend/public/js/stores/FeatureToggleServerFacade.js
2020-02-20 08:30:27 +01:00

100 lines
2.2 KiB
JavaScript

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