How to use rest-facade - 10 common examples

To help you get started, we’ve selected a few rest-facade examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github auth0 / node-auth0 / test / auth / database-auth.tests.js View on Github external
it('should require an options object', function() {
      expect(Authenticator).to.throw(ArgumentError, 'Missing authenticator options');

      expect(Authenticator.bind(null, 1)).to.throw(
        ArgumentError,
        'The authenticator options must be an object'
      );

      expect(Authenticator.bind(null, validOptions)).to.not.throw(ArgumentError);
    });
  });
github auth0 / node-auth0 / test / management / stats.tests.js View on Github external
it('should error when no options are provided', function() {
      expect(StatsManager).to.throw(ArgumentError, 'Must provide manager options');
    });
github auth0 / node-auth0 / test / retry-rest-client.tests.js View on Github external
describe('instance', function() {
    var client = new RetryRestClient(new RestClient(API_URL));
    var methods = ['getAll', 'get', 'create', 'update', 'delete'];

    methods.forEach(function(method) {
      it('should have a ' + method + ' method', function() {
        expect(client[method]).to.exist.to.be.an.instanceOf(Function);
      });
    });
  });
github auth0 / node-auth0 / test / retry-rest-client.tests.js View on Github external
before(function() {
    this.restClient = new RestClient(API_URL);
  });
github auth0 / node-auth0 / src / auth / TokensManager.js View on Github external
TokensManager.prototype.getDelegationToken = function(data, cb) {
  var body = extend({ client_id: this.clientId }, data);
  var headers = this.headers;

  if (!data) {
    throw new ArgumentError('Missing token data object');
  }

  var hasIdToken = typeof data.id_token === 'string' && data.id_token.trim().length !== 0;

  var hasRefreshToken =
    typeof data.refresh_token === 'string' && data.refresh_token.trim().length !== 0;

  if (!hasIdToken && !hasRefreshToken) {
    throw new ArgumentError('one of id_token or refresh_token is required');
  }

  if (hasIdToken && hasRefreshToken) {
    throw new ArgumentError('id_token and refresh_token fields cannot be specified simulatenously');
  }

  if (typeof data.target !== 'string' || data.target.trim().length === 0) {
github auth0 / node-auth0 / src / management / RolesManager.js View on Github external
var RolesManager = function(options) {
  if (options === null || typeof options !== 'object') {
    throw new ArgumentError('Must provide manager options');
  }

  if (options.baseUrl === null || options.baseUrl === undefined) {
    throw new ArgumentError('Must provide a base URL for the API');
  }

  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
    throw new ArgumentError('The provided base URL is invalid');
  }

  /**
   * Options object for the Rest Client instance.
   *
   * @type {Object}
   */
  var clientOptions = {
    headers: options.headers,
    query: { repeatParams: false }
  };

  /**
   * Provides an abstraction layer for performing CRUD operations on
   * {@link https://auth0.com/docs/api/v2#!/RolesManager Auth0 RolesManagers}.
   *
github auth0 / node-auth0 / src / management / UserBlocksManager.js View on Github external
UserBlocksManager.prototype.getByIdentifier = function(params) {
  if (typeof params !== 'object' || typeof params.identifier !== 'string') {
    throw new ArgumentError('You must provide an user identifier for the getByIdentifier method');
  }

  return this.userBlocksByIdentifier.get.apply(this.userBlocksByIdentifier, arguments);
};
github auth0 / node-auth0 / src / management / ConnectionsManager.js View on Github external
var ConnectionsManager = function(options) {
  if (options === null || typeof options !== 'object') {
    throw new ArgumentError('Must provide client options');
  }

  if (options.baseUrl === null || options.baseUrl === undefined) {
    throw new ArgumentError('Must provide a base URL for the API');
  }

  if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
    throw new ArgumentError('The provided base URL is invalid');
  }

  /**
   * Options object for the Rest Client instance.
   *
   * @type {Object}
   */
  var clientOptions = {
github auth0 / node-auth0 / src / management / EmailTemplatesManager.js View on Github external
var EmailTemplatesManager = function(options) {
  if (!options || 'object' !== typeof options) {
    throw new ArgumentError('Must provide manager options');
  }

  if (!options.baseUrl || 'string' !== typeof options.baseUrl) {
    throw new ArgumentError('Must provide a valid string as base URL for the API');
  }

  /**
   * Options object for the Rest Client instance.
   *
   * @type {Object}
   */
  var clientOptions = {
    headers: options.headers,
    query: { repeatParams: false }
  };
github auth0 / node-auth0 / src / auth / TokensManager.js View on Github external
var TokensManager = function(options) {
  if (typeof options !== 'object') {
    throw new ArgumentError('Missing tokens manager options');
  }

  if (typeof options.baseUrl !== 'string') {
    throw new ArgumentError('baseUrl field is required');
  }

  this.baseUrl = options.baseUrl;
  this.headers = options.headers || {};
  this.clientId = options.clientId || '';
};

rest-facade

Simple abstraction for consuming REST API endpoints

MIT
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis

Popular rest-facade functions