Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!settings.debug) {
client.patchGlobal(function() {
// It is highly discouraged to leave the process running after a
// global uncaught exception has occurred.
//
// https://github.com/getsentry/raven-node#catching-global-errors
// http://nodejs.org/api/process.html#process_event_uncaughtexception
//
console.log('Uncaught Exception process exiting');
process.exit(1);
});
}
// Server setup
var mongo = require('livedb-mongo')(settings.dbUrl, {safe:true});
var backend = livedb.client(mongo);
var share = sharejs.server.createClient({backend: backend});
var app = express();
var jsonParser = bodyParser.json();
var server = http.createServer(app);
var wss = new WebSocketServer({server: server});
// Local variables
var docs = {}; // TODO: Should this be stored in mongo?
var locked = {};
// Allow X-Forwarded-For headers
app.set('trust proxy');
// Raven Express Middleware
app.use(raven.middleware.express(settings.sentryDSN));
app.use(morgan('common'));
var share = require('share');
var sharePrimus = require('../lib');
var Primus = require('primus');
var argv = require('optimist').argv;
var app = express();
app.use(express.static(__dirname));
app.use(express.static(share.scriptsDir));
app.use(express.static(sharePrimus.scriptsDir));
var server = http.createServer(app);
var primus = new Primus(server, { transformer: argv.transformer });
primus.use('substream', require('substream'));
var db = new livedb.memory();
var backend = livedb.client(db);
var shareClient = share.server.createClient({backend:backend});
primus.on('connection', function (spark) {
console.log('New client');
var shareSpark = spark.substream('share');
// Workaround for https://github.com/primus/primus/issues/121
shareClient.listen(new sharePrimus.SparkStream(shareSpark));
// Send some non-share messages over the same stream
// Inspired by https://github.com/einaros/ws/blob/master/examples/serverstats/server.js
var processSpark = spark.substream('process');
var id = setInterval(function() {
processSpark.write(JSON.stringify(process.memoryUsage()));
}, 100);
spark.on('end', function() {
var async = require('async');
var cookie = require('cookie');
var signature = require('cookie-signature');
var livedbmongo = require('livedb-mongo');
import log = require('./logger');
import model = require('./model');
var Page = model.Page;
var PageVersion = model.PageVersion;
var User = model.User;
import options = require('./options-handler');
var database = livedbmongo(options['database']['uri']);
var backend = livedb.client(database);
import LiveSync = require('./livesync');
LiveSync.init(backend);
import AuthHelper = require('./auth-helper');
var pageConnectionMap = {};
export var init = function(app, mongoStore) {
var share = sharejs.server.createClient({
backend: backend
});
app.use(express.static(sharejs.scriptsDir));
app.use(browserChannel({
webserver: app,
sessionTimeoutInterval: 60*1000 // 60 second timeout
var livedb = require('livedb');
var share = require('share');
var sharePrimus = require('../lib');
var Primus = require('primus');
var argv = require('optimist').argv;
var app = express();
app.use(express.static(__dirname));
app.use(express.static(share.scriptsDir));
app.use(express.static(sharePrimus.scriptsDir));
var server = http.createServer(app);
var primus = new Primus(server, { transformer: argv.transformer });
primus.use('substream', require('substream'));
var db = new livedb.memory();
var backend = livedb.client(db);
var shareClient = share.server.createClient({backend:backend});
primus.on('connection', function (spark) {
console.log('New client');
var shareSpark = spark.substream('share');
// Workaround for https://github.com/primus/primus/issues/121
shareClient.listen(new sharePrimus.SparkStream(shareSpark));
// Send some non-share messages over the same stream
// Inspired by https://github.com/einaros/ws/blob/master/examples/serverstats/server.js
var processSpark = spark.substream('process');
var id = setInterval(function() {
processSpark.write(JSON.stringify(process.memoryUsage()));
}, 100);
var Duplex = require('stream').Duplex;
var browserChannel = require('browserchannel').server;
var livedb = require('livedb');
var sharejs = require('share');
var express = require('express');
var log = require('./logger').log;
var model = require('./model');
var Page = model.Page;
var PageVersion = model.PageVersion;
var User = model.User;
var database = livedb.memory();
var backend = livedb.client(database);
var LiveSync = require('./livesync');
LiveSync.init(backend.driver, database);
var pageConnectionMap = {};
exports.init = function(app) {
backend.addProjection('_users', 'users', 'json0', {
x: true
});
var share = sharejs.server.createClient({
backend: backend
});
app.use(express.static(sharejs.scriptsDir));
app.use(browserChannel({
webserver: app,
var Duplex = require('stream').Duplex;
var browserChannel = require('browserchannel').server;
var livedb = require('livedb');
var sharejs = require('share');
var express = require('express');
var log = require('./logger').log;
var model = require('./model');
var Page = model.Page;
var PageVersion = model.PageVersion;
var User = model.User;
var database = livedb.memory();
var backend = livedb.client(database);
var LiveSync = require('./livesync');
LiveSync.init(backend.driver, database);
var pageConnectionMap = {};
exports.init = function(app) {
backend.addProjection('_users', 'users', 'json0', {
x: true
});
var share = sharejs.server.createClient({
backend: backend
});
app.use(express.static(sharejs.scriptsDir));
app.use(browserChannel({
'use strict';
var Promise = require('bluebird');
var config = require('config');
var liveDBMongoClient = require('livedb-mongo');
var livedb = require('livedb');
var db = liveDBMongoClient(config.get('mongo'), {
safe: true
});
var backend = Promise.promisifyAll(livedb.client(db));
module.exports = backend;
var http = require('http');
var Duplex = require('stream').Duplex;
var browserChannel = require('browserchannel').server;
var express = require('express');
var livedb = require('livedb');
var sharejs = require('share');
var shareCodeMirror = require('..');
var backend = livedb.client(livedb.memory());
var share = sharejs.server.createClient({backend: backend});
var app = express();
app.use(express.static(__dirname));
app.use(express.static(shareCodeMirror.scriptsDir));
app.use(express.static(__dirname + '/../node_modules/codemirror/lib'));
app.use(express.static(sharejs.scriptsDir));
app.use(browserChannel(function (client) {
var stream = new Duplex({objectMode: true});
stream._write = function (chunk, encoding, callback) {
if (client.state !== 'closed') {
client.send(chunk);
}
callback();
};
stream._read = function () {