How to use the kuzzle-sdk.Kuzzle function in kuzzle-sdk

To help you get started, we’ve selected a few kuzzle-sdk 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 kuzzleio / sdk-javascript / doc / 6 / protocols / http / constructor / snippets / constructor.js View on Github external
'nyc-open-data-plugin/driver': {
    enroll: { verb: 'POST', url: '/_plugin/nyc-open-data-plugin/drivers' },
    remove: { verb: 'DELETE', url: '/_plugin/nyc-open-data-plugin/drivers/:driverId' }
  }
};

const options = {
  customRoutes,
  sslConnection: false
};

// Instantiates the Http protocol
const httpProtocol = new Http('kuzzle', options);

// Use it with Kuzzle
const kuzzle = new Kuzzle(httpProtocol);
github kuzzleio / kuzzle / features-sdk / support / hooks.js View on Github external
BeforeAll(({ timeout: 10 * 1000 }), async function () {
  const world = new World({});

  console.log(`Start tests with ${world.protocol.toLocaleUpperCase()} protocol.`);

  world.sdk = new Kuzzle(getProtocol(world));

  await world.sdk.connect();

  console.log('Loading default securities..');

  await world.sdk.query({
    controller: 'admin',
    action: 'loadSecurities',
    body: testSecurities,
    refresh: 'wait_for'
  });

  world.sdk.disconnect();
});
github kuzzleio / kuzzle / lib / core / plugins / context.js View on Github external
Reflect.defineProperty(this.accessors, 'strategies', {
        enumerable: true,
        get: () => {
          return {
            add: curryAddStrategy(kuzzle, pluginName),
            remove: curryRemoveStrategy(kuzzle, pluginName)
          };
        }
      });

      Reflect.defineProperty(this.accessors, 'trigger', {
        enumerable: true,
        get: () => curryTrigger(kuzzle, pluginName)
      });

      const kuzzleSdk = new KuzzleSDK(new FunnelProtocol(kuzzle.funnel));

      const throwNotAvailable = name => () => {
        contextError.throw('unavailable_realtime', name);
      };

      const getPluginSdk = sdk => ({
        query: sdk.query.bind(sdk),
        auth: sdk.auth,
        bulk: sdk.bulk,
        collection: sdk.collection,
        document: sdk.document,
        index: sdk.index,
        ms: sdk.ms,
        realtime: Object.assign(sdk.realtime, {
          subscribe: throwNotAvailable('realtime:subscribe'),
          unsubscribe: throwNotAvailable('realtime:unsubscribe')
github kuzzleio / kuzzle / features-sdk / support / world.js View on Github external
_getSdk () {
    let protocol;

    switch (this.protocol) {
      case 'http':
        protocol = new Http(this.host, { port: this.port });
        break;
      case 'websocket':
        protocol = new WebSocket(this.host, { port: this.port });
        break;
      default:
        throw new Error(`Unknown protocol "${this.protocol}".`);
    }

    return new Kuzzle(protocol);
  }
}
github kuzzleio / kuzzle / lib / core / plugins / context.js View on Github external
pluginSdk.as = user => {
            if (!(user instanceof User)) {
              contextError.throw('invalid_user');
            }

            return getPluginSdk(
              new KuzzleSDK(new FunnelProtocol(kuzzle.funnel, user)));
          };
github kuzzleio / kuzzle / features-sdk / support / hooks.js View on Github external
Before(({ timeout: 10 * 1000 }), async function () {
  this.sdk = new Kuzzle(getProtocol(this));

  await this.sdk.connect();
  await this.sdk.auth.login(
    'local',
    { username: 'test-admin', password: 'password' });

  await this.sdk.query({
    controller: 'admin',
    action: 'resetDatabase',
    refresh: 'wait_for'
  });
});

kuzzle-sdk

Official Javascript SDK for Kuzzle

Apache-2.0
Latest version published 6 months ago

Package Health Score

67 / 100
Full package analysis