Skip to content

Commit

Permalink
index: sort imports, remove unnecessary whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Apr 27, 2015
1 parent 9232d0d commit 5a9db39
Showing 1 changed file with 35 additions and 45 deletions.
80 changes: 35 additions & 45 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var moduleRoot = (function(_rootPath) {
*
* @api public
*/

var Keystone = function() {
prepost.mixin(this)
.register('pre:routes', 'pre:render');
Expand All @@ -41,29 +40,26 @@ var Keystone = function() {
'frame guard': 'sameorigin'
};
this._redirects = {};

// expose express

this.express = express;



// init environment defaults

this.set('env', process.env.NODE_ENV || 'development');

this.set('port', process.env.PORT || process.env.OPENSHIFT_NODEJS_PORT);
this.set('host', process.env.HOST || process.env.IP || process.env.OPENSHIFT_NODEJS_IP);
this.set('listen', process.env.LISTEN);

this.set('ssl', process.env.SSL);
this.set('ssl port', process.env.SSL_PORT);
this.set('ssl host', process.env.SSL_HOST || process.env.SSL_IP);
this.set('ssl key', process.env.SSL_KEY);
this.set('ssl cert', process.env.SSL_CERT);

this.set('cookie secret', process.env.COOKIE_SECRET);
this.set('cookie signin', (this.get('env') === 'development') ? true : false);

this.set('embedly api key', process.env.EMBEDLY_API_KEY || process.env.EMBEDLY_APIKEY);
this.set('mandrill api key', process.env.MANDRILL_API_KEY || process.env.MANDRILL_APIKEY);
this.set('mandrill username', process.env.MANDRILL_USERNAME);
Expand All @@ -74,81 +70,77 @@ var Keystone = function() {
this.set('chartbeat property', process.env.CHARTBEAT_PROPERTY);
this.set('chartbeat domain', process.env.CHARTBEAT_DOMAIN);
this.set('allowed ip ranges', process.env.ALLOWED_IP_RANGES);

if (process.env.S3_BUCKET && process.env.S3_KEY && process.env.S3_SECRET) {
this.set('s3 config', { bucket: process.env.S3_BUCKET, key: process.env.S3_KEY, secret: process.env.S3_SECRET, region: process.env.S3_REGION });
}

if (process.env.AZURE_STORAGE_ACCOUNT && process.env.AZURE_STORAGE_ACCESS_KEY) {
this.set('azurefile config', { account: process.env.AZURE_STORAGE_ACCOUNT, key: process.env.AZURE_STORAGE_ACCESS_KEY });
}

if (process.env.CLOUDINARY_URL) {
// process.env.CLOUDINARY_URL is processed by the cloudinary package when this is set
this.set('cloudinary config', true);
}

// Attach middleware packages, bound to this instance
this.middleware = {
api: require('./lib/middleware/api')(this),
cors: require('./lib/middleware/cors')(this)
};

};

_.extend(Keystone.prototype, require('./lib/core/options')());


Keystone.prototype.prefixModel = function (key) {
var modelPrefix = this.get('model prefix');

if (modelPrefix) {
key = modelPrefix + '_' + key;
}

return require('mongoose/lib/utils').toCollectionName(key);
};

/* Attach core functionality to Keystone.prototype */
Keystone.prototype.bindEmailTestRoutes = require('./lib/core/bindEmailTestRoutes');
Keystone.prototype.connect = require('./lib/core/connect');
Keystone.prototype.createItems = require('./lib/core/createItems');
Keystone.prototype.getOrphanedLists = require('./lib/core/getOrphanedLists');
Keystone.prototype.importer = require('./lib/core/importer');
Keystone.prototype.init = require('./lib/core/init');
Keystone.prototype.initNav = require('./lib/core/initNav');
Keystone.prototype.connect = require('./lib/core/connect');
Keystone.prototype.start = require('./lib/core/start');
Keystone.prototype.list = require('./lib/core/list');
Keystone.prototype.mount = require('./lib/core/mount');
Keystone.prototype.routes = require('./lib/core/routes');
Keystone.prototype.render = require('./lib/core/render');
Keystone.prototype.importer = require('./lib/core/importer');
Keystone.prototype.createItems = require('./lib/core/createItems');
Keystone.prototype.populateRelated = require('./lib/core/populateRelated');
Keystone.prototype.redirect = require('./lib/core/redirect');
Keystone.prototype.list = require('./lib/core/list');
Keystone.prototype.getOrphanedLists = require('./lib/core/getOrphanedLists');
Keystone.prototype.bindEmailTestRoutes = require('./lib/core/bindEmailTestRoutes');
Keystone.prototype.render = require('./lib/core/render');
Keystone.prototype.routes = require('./lib/core/routes');
Keystone.prototype.start = require('./lib/core/start');
Keystone.prototype.wrapHTMLError = require('./lib/core/wrapHTMLError');


/**
* The exports object is an instance of Keystone.
*
* @api public
*/

var keystone = module.exports = exports = new Keystone();

// Expose modules and Classes
keystone.utils = utils;
keystone.Keystone = Keystone;
keystone.content = require('./lib/content');
keystone.List = require('./lib/list');
keystone.Email = require('./lib/email');
keystone.Field = require('./fields/types/Type');
keystone.Field.Types = require('./lib/fieldTypes');
keystone.Keystone = Keystone;
keystone.List = require('./lib/list');
keystone.View = require('./lib/view');
keystone.Email = require('./lib/email');

keystone.content = require('./lib/content');
keystone.security = {
csrf: require('./lib/security/csrf')
};

keystone.utils = utils;

/**
* returns all .js modules (recursively) in the path specified, relative
Expand All @@ -163,18 +155,18 @@ keystone.security = {
*/

Keystone.prototype.import = function(dirname) {

var initialPath = path.join(this.get('module root'), dirname);

var doImport = function(fromPath) {

var imported = {};

fs.readdirSync(fromPath).forEach(function(name) {

var fsPath = path.join(fromPath, name),
info = fs.statSync(fsPath);

// recur
if (info.isDirectory()) {
imported[name] = doImport(fsPath);
Expand All @@ -186,12 +178,12 @@ Keystone.prototype.import = function(dirname) {
imported[base] = require(fsPath);
}
}

});

return imported;
};

return doImport(initialPath);
};

Expand All @@ -213,12 +205,10 @@ Keystone.prototype.applyUpdates = function(callback) {

Keystone.prototype.console = {};
Keystone.prototype.console.err = function(type, msg) {

if (keystone.get('logger')) {
var dashes = '\n------------------------------------------------\n';
console.log(dashes + 'KeystoneJS: ' + type + ':\n\n' + msg + dashes);
}

};

/**
Expand Down

0 comments on commit 5a9db39

Please sign in to comment.