Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function start_connections(logbucket_config, cachebucket_config) {
// Connect with couchbase server. All subsequent API calls
// to `couchbase` library is made via this Connection
var cb_db = new couchbase.Cluster(logbucket_config.connstr);
var cb_ca = new couchbase.Cluster(cachebucket_config.connstr);
db = cb_db.openBucket(logbucket_config.bucket, logbucket_config.password);
db.on('connect', function (err) {
db.operationTimeout = OPERATION_TIMEOUT;
if (err) {
console.error("Failed to connect to cluster: " + err);
process.exit(1);
}
console.log('Couchbase connected to ' + logbucket_config.bucket);
});
cache = cb_ca.openBucket(cachebucket_config.bucket, cachebucket_config.password);
cache.on('connect', function (err) {
if (err) {
console.error("Failed to connect to cluster: " + err);
process.exit(1);
}
exports.start = function(logbucket_config, cachebucket_config) {
// Connect with couchbase server. All subsequent API calls
// to `couchbase` library is made via this Connection
var cb_db = new couchbase.Cluster(logbucket_config.connstr);
var cb_ca = new couchbase.Cluster(cachebucket_config.connstr);
var db = cb_db.openBucket(logbucket_config.bucket, logbucket_config.password);
db.on('connect', function (err) {
if (err) {
console.error("Failed to connect to cluster: " + err);
process.exit(1);
}
console.log('Couchbase connected to ' + logbucket_config.bucket);
});
var cache = cb_ca.openBucket(cachebucket_config.bucket, cachebucket_config.password);
cache.on('connect', function (err) {
if (err) {
console.error("Failed to connect to cluster: " + err);
process.exit(1);
}
console.log('Couchbase connected to ' + cachebucket_config.bucket);
});
exports.start = function(logbucket_config, cachebucket_config) {
// Connect with couchbase server. All subsequent API calls
// to `couchbase` library is made via this Connection
var cb_db = new couchbase.Cluster(logbucket_config.connstr);
var cb_ca = new couchbase.Cluster(cachebucket_config.connstr);
var db = cb_db.openBucket(logbucket_config.bucket, logbucket_config.password);
db.on('connect', function (err) {
if (err) {
console.error("Failed to connect to cluster: " + err);
process.exit(1);
}
console.log('Couchbase connected to ' + logbucket_config.bucket);
});
var cache = cb_ca.openBucket(cachebucket_config.bucket, cachebucket_config.password);
cache.on('connect', function (err) {
if (err) {
console.error("Failed to connect to cluster: " + err);
process.exit(1);
}
console.log('Couchbase connected to ' + cachebucket_config.bucket);
function start_connections(logbucket_config, cachebucket_config) {
// Connect with couchbase server. All subsequent API calls
// to `couchbase` library is made via this Connection
var cb_db = new couchbase.Cluster(logbucket_config.connstr);
var cb_ca = new couchbase.Cluster(cachebucket_config.connstr);
db = cb_db.openBucket(logbucket_config.bucket, logbucket_config.password);
db.on('connect', function (err) {
db.operationTimeout = OPERATION_TIMEOUT;
if (err) {
console.error("Failed to connect to cluster: " + err);
process.exit(1);
}
console.log('Couchbase connected to ' + logbucket_config.bucket);
});
cache = cb_ca.openBucket(cachebucket_config.bucket, cachebucket_config.password);
cache.on('connect', function (err) {
if (err) {
console.error("Failed to connect to cluster: " + err);
process.exit(1);
}
console.log('Couchbase connected to ' + cachebucket_config.bucket);
onFileUploadStart: function (file) {
console.log(file.originalname + ' is starting ...')
},
onFileUploadComplete: function (file) {
console.log(file.fieldname + ' uploaded to ' + file.path)
done=true;
},
limits: {
fieldNameSize: 100,
fileSize: 20000000,
files: 1
}
}));
// create cluster and create buckets using config file
var cluster = new couchbase.Cluster(config.couchbase.server);
module.exports.userBucket = cluster.openBucket(config.couchbase.userBucket);
module.exports.pictureBucket = cluster.openBucket(config.couchbase.pictureBucket);
module.exports.publishBucket = cluster.openBucket(config.couchbase.publishBucket);
// include API endpoints
var routes = require("./routes/routes.js")(app);
// set up HTTP and HTTPS if possible
var httpServer = http.createServer(app);
var httpsServer = https.createServer(options, app);
httpServer.listen(config.couchbase.TouchbasePort);
httpsServer.listen(8443);
/*https.createServer({
key: options.key,
cert: options.cert
}, app).listen(443);*/
/**
*
* @type {exports}
*/
var config = require('./../config');
var couchbase = require('couchbase');
var endPoint = config.couchbase.endPoint;
var bucket = config.couchbase.bucket;
var myCluster = new couchbase.Cluster(endPoint);
var ODMBucket;// = myCluster.openBucket(bucket);
var db;
var http=require('http');
var request=require('request');
var status="offline"; //offline,pending,online
var ottoman = require('ottoman');
var faye = require('faye');
var client = new faye.Client('http://localhost:8000/faye');
var ProgressBar = require('progress');
var barDone=false;
var bar = new ProgressBar(' LOADING [:bar] :percent :etas', {
complete: '=',
incomplete: ' ',
total: 20
});
app.use(multer({dest: './uploads/',
onFileUploadStart: function (file) {
console.log(file.originalname + ' is starting ...')
},
onFileUploadComplete: function (file) {
console.log(file.fieldname + ' uploaded to ' + file.path)
done=true;
},
limits: {
fieldNameSize: 100,
fileSize: 20000000,
files: 1
}
}));
var cluster = new couchbase.Cluster(config.couchbase.server);
module.exports.userBucket = cluster.openBucket(config.couchbase.userBucket);
module.exports.pictureBucket = cluster.openBucket(config.couchbase.pictureBucket);
module.exports.publishBucket = cluster.openBucket(config.couchbase.publishBucket);
var routes = require("./routes/routes.js")(app);
var httpServer = http.createServer(app);
var httpsServer = https.createServer(options, app);
httpServer.listen(config.couchbase.TouchbasePort);
httpsServer.listen(8443);
/*https.createServer({
key: options.key,
cert: options.cert
}, app).listen(443);*/
//http.createServer(app).listen(80);
return new Promise((resolve, reject) => {
this.cluster = new Couchbase.Cluster(this.options.cluster);
this.cluster.authenticate(this.options.username, this.options.password);
this.bucket = this.cluster.openBucket(this.options.bucket, (err: Couchbase.CouchbaseError) => {
if (err) {
return reject(err);
}
return resolve();
});
});
}
require('dotenv').config();
const express = require('express');
const debug = require('debug')('poi:server');
const path = require('path');
const favicon = require('serve-favicon');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const http = require('http');
const https = require('https');
const fs = require('fs');
const couchbase = require('couchbase');
const cluster = new couchbase.Cluster(process.env.CLUSTER);
cluster.authenticate(process.env.CLUSTER_USER, process.env.CLUSTER_PASSWORD);
const app = express();
app.locals.couchbase = couchbase;
app.locals.cluster = cluster;
app.locals.travel = cluster.openBucket('travel-sample');
app.locals.eventing = cluster.openBucket('eventing');
app.use(favicon(path.join(__dirname, 'images/favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
return new Promise((resolve, reject) => {
this.cluster = new Cluster(this.options.host);
if (this.options.username && this.options.password) {
this.cluster.authenticate(
this.options.username,
this.options.password,
);
}
this.bucket = this.cluster.openBucket(this.options.bucketName);
this.bucket.on('connect', resolve);
this.bucket.on('error', reject);
this.configure();
});
}