Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
call: noDdp,
apply: noDdp,
execute: noDdp
};
log.debug('[chimp][helper] DDP not required');
}
};
var configureChimpWidgetsDriver = function configureChimpWidgetsDriver() {
widgets.driver.api = global.browser;
};
try {
setupBrowser();
initBrowser();
if (booleanHelper.isTruthy(process.env['chimp.ddp'])) {
setupDdp();
}
configureChimpWidgetsDriver();
} catch (error) {
log.error('[chimp][helper] setupBrowserAndDDP had error');
log.error(error);
log.error(error.stack);
exit(2);
}
},
var setupDdp = function setupDdp() {
log.debug('[chimp][helper] setup DDP');
if (process.env['chimp.ddp']) {
log.debug('[chimp][helper] connecting via DDP to', process.env['chimp.ddp']);
try {
global.ddp.connectSync();
addServerExecute();
log.debug('[chimp][helper] connecting via DDP had no error');
} catch (error) {
log.error('[chimp][helper] connecting via DDP error', error);
}
} else {
var noDdp = function noDdp() {
expect('DDP Not Connected').to.equal('', 'You tried to use a DDP connection but it' + ' has not been configured. Be sure to pass --ddp=');
};
global.ddp = {
call: noDdp,
apply: noDdp,
execute: noDdp
Chimp.prototype._startServer = function (port) {
var server = new Hapi.Server();
server.connection({
host: this.options.serverHost,
port: port,
routes: { timeout: { server: false, socket: false } }
});
this._setupRoutes(server);
server.start();
log.info('[chimp] Chimp server is running on port', port, process.env['chimp.ddp']);
if (booleanHelper.isTruthy(this.options.ddp)) {
this._handshakeOverDDP();
}
};
var setupDdp = function setupDdp() {
log.debug('[chimp][helper] setup DDP');
if (process.env['chimp.ddp']) {
log.debug('[chimp][helper] connecting via DDP to', process.env['chimp.ddp']);
try {
global.ddp.connectSync();
addServerExecute();
log.debug('[chimp][helper] connecting via DDP had no error');
} catch (error) {
log.error('[chimp][helper] connecting via DDP error', error);
}
} else {
var noDdp = function noDdp() {
expect('DDP Not Connected').to.equal('', 'You tried to use a DDP connection but it' + ' has not been configured. Be sure to pass --ddp=');
};
global.ddp = {
call: noDdp,
apply: noDdp,
execute: noDdp
};
Chimp.prototype._startServer = function (port) {
var server = new Hapi.Server();
server.connection({
host: this.options.serverHost,
port: port,
routes: {timeout: {server: false, socket: false}}
});
this._setupRoutes(server);
server.start();
log.info('[chimp] Chimp server is running on port', port, process.env['chimp.ddp']);
if (booleanHelper.isTruthy(this.options.ddp)) {
this._handshakeOverDDP();
}
};
Chimp.prototype._handshakeOverDDP = function () {
var ddp = new DDPClient({
host: process.env['chimp.ddp'].match(/http:\/\/(.*):/)[1],
port: process.env['chimp.ddp'].match(/:([0-9]+)/)[1],
ssl: false,
autoReconnect: true,
autoReconnectTimer: 500,
maintainCollections: true,
ddpVersion: '1',
useSockJs: true
});
ddp.connect(function (error) {
if (error) {
log.error('[chimp] Error handshaking via DDP');
throw (error);
}
}).then(function () {
log.debug('[chimp] Handshaking with DDP server');
ddp.call('handshake').then(function () {
log.debug('[chimp] Handshake complete, closing DDP connection');
Chimp.prototype._handshakeOverDDP = function () {
var ddp = new DDPClient({
host: process.env['chimp.ddp'].match(/http:\/\/(.*):/)[1],
port: process.env['chimp.ddp'].match(/:([0-9]+)/)[1],
ssl: false,
autoReconnect: true,
autoReconnectTimer: 500,
maintainCollections: true,
ddpVersion: '1',
useSockJs: true
});
ddp.connect(function (error) {
if (error) {
log.error('[chimp] Error handshaking via DDP');
throw error;
}
}).then(function () {
log.debug('[chimp] Handshaking with DDP server');
ddp.call('handshake').then(function () {
log.debug('[chimp] Handshake complete, closing DDP connection');