How to use the derby.createApp 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 derbyjs / derby-site / src / server / site.js View on Github external
var path = require('path');
var glob = require('glob');
var parseUrl = require('url').parse;
var derby = require('derby');
var express = require('express');
var app = derby.createApp('site', __filename);

app.serverUse(module, './markdown');
app.serverUse(module, 'derby-stylus');

app.loadViews(__dirname + '/../../views/app');
app.loadStyles(__dirname + '/../../styles/app');

// TODO move this view function elsewhere
// check if the link matches the first parts of the page's namespace
// so that we can highlight 'docs' when in any sub page
app.proto.linkMatch = function(url, render) {
  var segments = url.split('/');
  var ns = render.ns.split(':');
  var i = 1;
  for(i; i < segments.length; i++) {
    if(segments[i] !== ns[i-1]) return false;
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){
  //   console.log('!');
  //   app.page.render();
  // });
github derbyjs / derby-site / src / app / index.js View on Github external
var derby = require('derby');
var markedOptions = require('./../../config/markedOptions');
var path = require('path');
var app = module.exports = derby.createApp('site', __filename);

if (!derby.util.isProduction) global.app = app;

app.serverUse(module, 'derby-markdown', markedOptions);
app.serverUse(module, 'derby-stylus');
app.loadViews(path.join(__dirname, '/../../views/app'));
app.loadStyles(path.join(__dirname, '/../../styles/app'));
app.component(require('../../components/chat'));
app.component(require('../../components/preferences'));
app.component(require('../../components/sidebar'));

app.get('*', function (page, model, params, next) {
  // it`s used to cheat template engine in derby-template examples
  model.set('_session.openBrackets', '{{');
  if (model.get('_session.loggedIn')) {
    var userId = model.get('_session.userId');
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 / 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',{
github alexyoung / nodejsinaction / ch05-server-side-frameworks / example-derby-app / app / index.js View on Github external
const app = module.exports = require('derby').createApp('hello', __filename);
app.loadViews(__dirname);

// Routes render on client as well as server
app.get('/', (page, model) => {
  // Subscribe specifies the data to sync
  const message = model.at('hello.message');
  message.subscribe(err => {
    if (err) return next(err);
    message.createNull('');
    page.render();
  });
});
github azat-co / proexpressjs / ch18 / derby / derby-app.js View on Github external
var path = require('path'),
  derby = require('derby'),
  app = derby.createApp('derby-app', __filename);

module.exports = app;
app.serverUse(module, 'derby-less');
app.loadViews (path.join(__dirname, 'views', 'derby-app'));
app.loadStyles(path.join(__dirname, 'styles', 'derby-app'));

app.get('/', function(page, model, params) {
  model.subscribe('d.message', function() {
    page.render();
  });
});

app.proto.create = function(model) {
  model.on('set', 'd.message', function(path, object) {
    console.log('message has been changed: ' + object);
  });
github derbyjs / derby-site / src / server / error.js View on Github external
var derby = require('derby');

var errorApp = derby.createApp();
errorApp.serverUse(module, 'derby-stylus');
errorApp.loadViews(__dirname + '/../../views/error');
errorApp.loadStyles(__dirname + '/../../styles/error');

module.exports = function(err, req, res, next) {
  if (!err) return next();

  var message = err.message || err.toString();
  var status = parseInt(message);
  status = ((status >= 400) && (status < 600)) ? status : 500;

  if (status < 500) {
    console.log(err.message || err);
  } else {
    console.log(err.stack || err);
  }
github derbyjs / derby / bin / bare-js / lib / $$app$$ / index.js View on Github external
var app = require('derby').createApp(module)
  .use(require('../../ui'))

app.get('/', function(page) {
  page.render();
});

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