SDK
SDK Javascript v6.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

Constructor #

Use this constructor to create a new instance of the Http protocol with specific options.

Arguments #

Copied to clipboard!
Http(host, [options]);

Argument Type Description
host
string
Kuzzle server hostname or IP
options
object
Http connection options

options #

Http protocol connection options.

Property Type
(default)
Description
port
number

(7512)
Kuzzle server port
sslConnection
boolean

(false)
Use SSL to connect to Kuzzle server
customRoutes
object

({})
Add custom routes
Available since 6.2.0
timeout
number

(0)
Connection timeout in milliseconds (0 means no timeout)
Available since 6.2.1

Note:

customRoutes are used to define plugins API routes or to overwrite existing API routes.
They must have the following format:

Copied to clipboard!
{
  'my-plugin/my-controller': {
    action: { verb: 'GET', url: '/some/url' },
    action2: { verb: 'GET', url: '/some/url/with/:parameter' }
  }
}

Return #

A Http protocol instance.

Usage #

Copied to clipboard!
// Loads the Http protocol
const
  {
    Kuzzle,
    Http
  } = require('kuzzle-sdk');
const customRoutes = {
  '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);