How to use the juice.Application function in juice

To help you get started, we’ve selected a few juice 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 ashb / juice / skeleton / lib / app.js View on Github external
// Don't mess these first few lines
const juice = require('juice');

var app = new juice.Application(module),
    proto = app.prototype;

/*
Example model:
var DB = proto.models.DB = function( app ) {
  this.db = new require('sqlite3').SQLite3( app.config.dbname );
}

DB.prototype.all = function() {
  return this.db.query("SELECT * FROM table");
}

Then use it in a controller like:
proto.controllers.list = function ( ) {
  return { rows: this.models.DB.all() }
}