Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} = 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);
function getProtocol (world) {
let protocol;
switch (world.protocol) {
case 'http':
protocol = new Http(world.host, { port: world.port });
break;
case 'websocket':
protocol = new WebSocket(world.host, { port: world.port });
break;
default:
throw new Error(`Unknown protocol "${world.protocol}".`);
}
return protocol;
}
_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);
}
}