features icon indicating copy to clipboard operation
features copied to clipboard

Features JS SDK

Open albertoleal opened this issue 11 years ago • 0 comments

Create a Javascript SDK that allows the developer to store and manage features in just a few lines of code.

An example of the API will look like the following:

var Features = require('features').Features;
Features.initialize("http://features.apimanager.org") 

// Creates/Updates a feature
Features.save({
  key: 'search_by_email',
  enabled: true,
  users: [],
  groups: [],
  percentage: 20
})

// Deletes a feature without callbacks.
Features.delete('search_by_email')

// Deletes a feature with callbacks.
Features.delete({
  key: 'search_by_email'
}, function(data, stats) {
// success callback.
}).fail(function(request, err) {
  // fail callback.
}).complete(function() {
  // complete callback, it will always be called.
})

// Enables a specific feature.
Features.enable('search_by_email')

// Disables a specific feature.
Features.disable('search_by_email')

// Retrives all features.
Features.all()

// Retrives all enabled features.
Features.all({enabled: true}) // http://my.api.com/features?enabled=true

// Searches for a specific feature.
// without callbacks
Features.byKey({key: 'search_by_email'})

// with all callbacks
Features.byKey({key: 'search_by_email'}, function(data, stats) {
// success callback.
}).fail(function(request, err) {
  // fail callback.
}).complete(function() {
  // complete callback, it will always be called.
})

albertoleal avatar Oct 29 '15 15:10 albertoleal