How to use the derby.use function in derby

To help you get started, we’ve selected a few derby 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 azat-co / mongoui / main.js View on Github external
var derby = require('derby');
derby.use(require('./ui'));
derby.use(require('derby-ui-boot'));


var app = derby.createApp(module);



app.ready(function(model) {

  // console.log(app.page)
  // model.on('set','dbName',function(path,object){
  // });
  // model.on('set','collectionBox', function(path,obj){
  //   console.log('$');
  //   app.page.render();
  // });
  // model.on('set','collections',function(path,obj){
github lefnire / derby-auth / example / lib / auth / index.js View on Github external
var derby = require('derby')
    , app = derby.createApp(module)
    , get = app.get

derby.use(require('derby-ui-boot'));
derby.use(require('../../ui'));
derby.use(require('../../../components'));

get('/', function(page, model) {
  model.query('users').withId(model.get('_userId')).subscribe(function(err, user) {
    model.ref('_user', user);
    page.render();
  });
});

app.ready(function(model) {
    // nothing here
});
github triptec / derby-learn-by-example / lib / server / index.js View on Github external
, path = require('path')
  , express = require('express')
  , gzippo = require('gzippo')
  , derby = require('derby')
  , auth = require('derby-auth')
  , app = require('../app')
  , serverError = require('./serverError')


// SERVER CONFIGURATION //

var expressApp = express()
  , server = module.exports = http.createServer(expressApp)

derby.use(derby.logPlugin)
derby.use(require('racer-db-mongo')); // This line is new

var store = derby.createStore({
  listen: server,
  db:      {type: 'Mongo', uri: process.env.MONGOHQ_URL || 'mongodb://localhost/snippets'}
})

//Authentication
auth.store(store);

var options, strategies;
strategies = {
  facebook: {
    strategy: require("passport-facebook").Strategy,
    conf: {
      clientID: process.env.FACEBOOK_KEY,
      clientSecret: process.env.FACEBOOK_SECRET
github triptec / derby-learn-by-example / lib / app / index.js View on Github external
var derby = require('derby')
  , app = derby.createApp(module)
  , get = app.get
  , view = app.view
  , ready = app.ready
  , start = +new Date()

derby.use(require('../../ui'))
derby.use(require('../../components'));

// ROUTES //

get('/', function(page, model, params) {

    model.subscribe('snippster.data', function(err, data){
        if(err)
            throw err;
        model.set('_snippet',{
                        title: "title",
                        description: "description",
                        source: "source"
                    });

        model.ref('_snippets', data.path() +".snippets");
github derbyjs / derby-site / server / index.js View on Github external
var path = require('path');

var racerBrowserChannel = require('racer-browserchannel');
var liveDbMongo = require('livedb-mongo');
var racerBundle = require('racer-bundle');

var error = require('./error');

var mongoUrl = process.env.MONGO_URL + process.env.MONGO_DB;

var connectStore = require('connect-mongo')(session);
var sessionStore = new connectStore({url: mongoUrl});

store = derby.createStore({db: liveDbMongo(mongoUrl + '?auto_reconnect', {safe: true})});

derby.use(racerBundle);

var publicDir = path.join(__dirname, '/../public');
var loginOptions = require('./../config/loginOptions');

hooks(store);

var expressApp = module.exports = express()
  .use(favicon(path.join(publicDir, '/images/favicon.ico')))
  .use(compression())
  .use(serveStatic(publicDir))
  .use(cookieParser(process.env.SESSION_COOKIE))
  .use(session({
    secret: process.env.SESSION_SECRET,
    store: sessionStore
  }))
  .use(racerBrowserChannel(store))
github derbyjs / derby-site / src / server / server.js View on Github external
var redisClient;
  redisClient = redis.createClient(process.env.REDIS_PORT, process.env.REDIS_HOST);
  if (process.env.REDIS_PASSWORD) redisClient.auth(process.env.REDIS_PASSWORD);

  connectStore = require('connect-redis')(session);
  sessionStore = new connectStore({host: process.env.REDIS_HOST, port: process.env.REDIS_PORT, pass: process.env.REDIS_PASSWORD});
} else {
  connectStore = require('connect-mongo')(session);
  sessionStore = new connectStore({url: process.env.MONGO_URL});
}

var midError = require('./error');
var derby = require('derby');
var racerBrowserChannel = require('racer-browserchannel');
var liveDbMongo = require('livedb-mongo');
derby.use(require('racer-bundle'));

exports.setup = function setup(app, options, cb) {
  var store = derby.createStore({
    db: liveDbMongo(process.env.MONGO_URL + '?auto_reconnect', {safe: true}),
    redis: redisClient
  });

  var publicDir = path.join(__dirname, '/../../public');

  var expressApp = express()
    .use(favicon(path.join(publicDir, '/images/favicon.ico')))
    .use(compression())
    .use(serveStatic(publicDir));

  if (options && options.static) {
    if (Array.isArray(options.static)) {
github lefnire / derby-auth / example / lib / server / index.js View on Github external
var http = require('http')
  , path = require('path')
  , express = require('express')
  , gzippo = require('gzippo')
  , derby = require('derby')
  , app = require('../auth')
  , serverError = require('./serverError')
  , MongoStore = require('connect-mongo')(express)
  , dbUri = 'mongodb://localhost/derby-auth';

var expressApp = express(),
    server = http.createServer(expressApp)

derby.use(require('racer-db-mongo'));
var store = derby.createStore({
  db: { type: 'Mongo', uri: dbUri, safe: true },
  listen: server
});

module.exports = server

var ONE_YEAR = 1000 * 60 * 60 * 24 * 365
    , root = path.dirname(path.dirname(__dirname))
    , publicPath = path.join(root, 'public')

/**
 * (1)
 * Setup a hash of strategies you'll use - strategy objects and their configurations
 * Note, API keys should be stored as environment variables (eg, process.env.FACEBOOK_KEY, process.env.FACEBOOK_SECRET)
 * rather than a configuration file. We're storing it in conf.js for demo purposes.

derby

MVC framework making it easy to write realtime, collaborative applications that run in both Node.js and browsers.

MIT
Latest version published 3 days ago

Package Health Score

79 / 100
Full package analysis