How to use the livedb.client function in livedb

To help you get started, we’ve selected a few livedb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CenterForOpenScience / osf.io / website / addons / wiki / shareServer.js View on Github external
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'));
github cucumber-ltd / share-primus / example / server.js View on Github external
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() {
github MisterTea / TidalWave / server / sharejs-handler.ts View on Github external
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
github MisterTea / TidalWave / TidalWave / server / sharejs-handler.js View on Github external
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,
github code-friends / CodeFriends / server / liveDbClient.js View on Github external
'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;

livedb

Realtime database wrapper

MIT
Latest version published 9 years ago

Package Health Score

61 / 100
Full package analysis

Popular livedb functions