How to use the rest-facade.Client function in rest-facade

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 / 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 / Auth0RestClient.js View on Github external
var Auth0RestClient = function(resourceUrl, options, provider) {
  if (resourceUrl === null || resourceUrl === undefined) {
    throw new ArgumentError('Must provide a Resource Url');
  }

  if ('string' !== typeof resourceUrl || resourceUrl.length === 0) {
    throw new ArgumentError('The provided Resource Url is invalid');
  }

  if (options === null || typeof options !== 'object') {
    throw new ArgumentError('Must provide options');
  }

  this.options = options;
  this.provider = provider;
  this.restClient = new RestClient(resourceUrl, options);

  this.wrappedProvider = function(method, args) {
    if (!this.provider) {
      return this.restClient[method].apply(this.restClient, args);
    }

    var callback;
    if (args && args[args.length - 1] instanceof Function) {
      callback = args[args.length - 1];
    }

    var self = this;
    return this.provider
      .getAccessToken()
      .then(function(access_token) {
        self.restClient.options.headers['Authorization'] = 'Bearer ' + access_token;
github auth0 / node-auth0 / src / auth / OAuthAuthenticator.js View on Github external
if (typeof options !== 'object') {
    throw new ArgumentError('The authenticator options must be an object');
  }

  /**
   * Options object for the Rest Client instace.
   *
   * @type {Object}
   */
  var clientOptions = {
    errorCustomizer: SanitizedError,
    errorFormatter: { message: 'message', name: 'error' },
    headers: options.headers
  };

  this.oauth = new RestClient(options.baseUrl + '/oauth/:type', clientOptions);
  this.oauthWithIDTokenValidation = new OAUthWithIDTokenValidation(this.oauth, options);
  this.clientId = options.clientId;
  this.clientSecret = options.clientSecret;
};
github auth0 / node-auth0 / src / auth / PasswordlessAuthenticator.js View on Github external
if (typeof options !== 'object') {
    throw new ArgumentError('The authenticator options must be an object');
  }

  /**
   * Options object for the Rest Client instace.
   *
   * @type {Object}
   */
  var clientOptions = {
    errorFormatter: { message: 'message', name: 'error' },
    headers: options.headers
  };

  this.oauth = oauth;
  this.passwordless = new RestClient(options.baseUrl + '/passwordless/start', clientOptions);
  this.clientId = options.clientId;
};
github auth0 / node-auth0 / src / auth / SAMLAuthenticator.js View on Github external
var SAMLAuthenticator = function (options) {
  if (!options) {
    throw new ArgumentError('Missing authenticator options');
  }

  if (typeof options !== 'object') {
    throw new ArgumentError('The authenticator options must be an object');
  }

  var samlUrl = options.baseUrl + '/samlp/:type/:client_id';

  this.saml = new RestClient(samlUrl);
  this.clientId = options.clientId;
};
github auth0 / node-auth0 / src / auth / DatabaseAuthenticator.js View on Github external
if (typeof options !== 'object') {
    throw new ArgumentError('The authenticator options must be an object');
  }

  /**
   * Options object for the Rest Client instace.
   *
   * @type {Object}
   */
  var clientOptions = {
    errorFormatter: { message: 'message', name: 'error' },
    headers: options.headers
  };

  this.oauth = oauth;
  this.dbConnections = new RestClient(options.baseUrl + '/dbconnections/:type', clientOptions);
  this.clientId = options.clientId;
};

rest-facade

Simple abstraction for consuming REST API endpoints

MIT
Latest version published 1 year ago

Package Health Score

59 / 100
Full package analysis

Popular rest-facade functions