Skip to content

Instantly share code, notes, and snippets.

@tylerstalder
Created July 15, 2014 15:41
Show Gist options
  • Save tylerstalder/0132ed0582816d67c3fa to your computer and use it in GitHub Desktop.
Save tylerstalder/0132ed0582816d67c3fa to your computer and use it in GitHub Desktop.
Requiring ezel-apps
//
// Sets up intial project settings, middleware, mounted apps, and
// global configuration such as overriding Backbone.sync and
// populating sharify data
//
var c = require('../config'),
express = require('express'),
Backbone = require('backbone'),
sharify = require('sharify'),
path = require('path'),
superSync = require('backbone-super-sync'),
util = require('util');
// Inject some constant data into sharify
sharify.data = {
SERVICE_HOST: c.SERVICE_HOST,
PORT: c.PORT
};
module.exports = function(app) {
// Override Backbone to use server-side sync
superSync.editRequest = function(req, method, model, options) {
if (options.auth) {
req.set({'Authorization': "Bearer " + options.auth});
}
};
Backbone.sync = superSync;
// Mount sharify
app.use(sharify);
// Mount apps
app.use(require('../apps/auth'));
app.use(require('ezel-commits');
app.use(require('ezel-app2');
// More general middleware
app.use(express.static(path.resolve(__dirname, '../public')));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment