using two spaces for tabs

This commit is contained in:
Mario Colque 2014-01-06 14:37:32 -03:00
parent 79e6cdfffd
commit e33ee06cc6
9 changed files with 84 additions and 84 deletions

View File

@ -1,5 +1,5 @@
'use strict'; 'use strict';
exports.render = function(req, res) { exports.render = function(req, res) {
res.render('index'); res.render('index');
}; };

View File

@ -5,5 +5,5 @@ var _ = require('lodash');
// Load app configuration // Load app configuration
module.exports = _.extend( module.exports = _.extend(
require(__dirname + '/../config/env/all.js'), require(__dirname + '/../config/env/all.js'),
require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.js') || {}); require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.js') || {});

6
config/env/all.js vendored
View File

@ -4,7 +4,7 @@ var path = require('path'),
rootPath = path.normalize(__dirname + '/../..'); rootPath = path.normalize(__dirname + '/../..');
module.exports = { module.exports = {
root: rootPath, root: rootPath,
port: process.env.PORT || 3000, port: process.env.PORT || 3000,
db: process.env.MONGOHQ_URL db: process.env.MONGOHQ_URL
} }

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
module.exports = { module.exports = {
db: "mongodb://localhost/mystery-dev", db: "mongodb://localhost/mystery-dev",
app: { app: {
name: "Mystery - Development" name: "Mystery - Development"
} }
} }

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
module.exports = { module.exports = {
db: "mongodb://localhost/mystery", db: "mongodb://localhost/mystery",
app: { app: {
name: "Mystery - Production" name: "Mystery - Production"
} }
} }

10
config/env/test.js vendored
View File

@ -1,9 +1,9 @@
'use strict'; 'use strict';
module.exports = { module.exports = {
db: "mongodb://localhost/mystery-test", db: "mongodb://localhost/mystery-test",
port: 3001, port: 3001,
app: { app: {
name: "Mystery - Test" name: "Mystery - Test"
} }
} }

View File

@ -4,66 +4,66 @@
* Module dependencies. * Module dependencies.
*/ */
var express = require('express'), var express = require('express'),
config = require('./config'); config = require('./config');
module.exports = function(app, passport, db) { module.exports = function(app, passport, db) {
app.set('showStackError', true); app.set('showStackError', true);
//Prettify HTML //Prettify HTML
app.locals.pretty = true; app.locals.pretty = true;
//Should be placed before express.static //Should be placed before express.static
app.use(express.compress({ app.use(express.compress({
filter: function(req, res) { filter: function(req, res) {
return (/json|text|javascript|css/).test(res.getHeader('Content-Type')); return (/json|text|javascript|css/).test(res.getHeader('Content-Type'));
}, },
level: 9 level: 9
})); }));
//Set views path, template engine and default layout //Set views path, template engine and default layout
app.set('views', config.root + '/app/views'); app.set('views', config.root + '/app/views');
app.set('view engine', 'jade'); app.set('view engine', 'jade');
//Enable jsonp //Enable jsonp
app.enable("jsonp callback"); app.enable("jsonp callback");
app.configure(function() { app.configure(function() {
//cookieParser should be above session //cookieParser should be above session
app.use(express.cookieParser()); app.use(express.cookieParser());
// request body parsing middleware should be above methodOverride // request body parsing middleware should be above methodOverride
app.use(express.urlencoded()); app.use(express.urlencoded());
app.use(express.json()); app.use(express.json());
app.use(express.methodOverride()); app.use(express.methodOverride());
//routes should be at the last //routes should be at the last
app.use(app.router); app.use(app.router);
//Setting the fav icon and static folder
app.use(express.favicon());
app.use(express.static(config.root + '/public'));
//Assume "not found" in the error msgs is a 404. this is somewhat silly, but valid, you can do whatever you like, set properties, use instanceof etc. //Setting the fav icon and static folder
app.use(function(err, req, res, next) { app.use(express.favicon());
//Treat as 404 app.use(express.static(config.root + '/public'));
if (~err.message.indexOf('not found')) return next();
//Log it //Assume "not found" in the error msgs is a 404. this is somewhat silly, but valid, you can do whatever you like, set properties, use instanceof etc.
console.error(err.stack); app.use(function(err, req, res, next) {
//Treat as 404
if (~err.message.indexOf('not found')) return next();
//Error page //Log it
res.status(500).render('500', { console.error(err.stack);
error: err.stack
});
});
//Assume 404 since no middleware responded
app.use(function(req, res, next) {
res.status(404).render('404', {
url: req.originalUrl,
error: 'Not found'
});
});
//Error page
res.status(500).render('500', {
error: err.stack
});
}); });
//Assume 404 since no middleware responded
app.use(function(req, res, next) {
res.status(404).render('404', {
url: req.originalUrl,
error: 'Not found'
});
});
});
}; };

View File

@ -2,8 +2,8 @@
module.exports = function(app) { module.exports = function(app) {
//Home route //Home route
var index = require('../app/controllers/index'); var index = require('../app/controllers/index');
app.get('/', index.render); app.get('/', index.render);
}; };

View File

@ -4,7 +4,7 @@
* Module dependencies. * Module dependencies.
*/ */
var express = require('express'), var express = require('express'),
fs = require('fs'); fs = require('fs');
/** /**
* Main application entry file. * Main application entry file.
@ -14,9 +14,9 @@ var express = require('express'),
//Set the node enviornment variable if not set before //Set the node enviornment variable if not set before
process.env.NODE_ENV = process.env.NODE_ENV || 'development'; process.env.NODE_ENV = process.env.NODE_ENV || 'development';
//Initializing system variables //Initializing system variables
var config = require('./config/config'), var config = require('./config/config'),
mongoose = require('mongoose'); mongoose = require('mongoose');
//Bootstrap db connection //Bootstrap db connection
var db = mongoose.connect(config.db); var db = mongoose.connect(config.db);
@ -24,17 +24,17 @@ var db = mongoose.connect(config.db);
//Bootstrap models //Bootstrap models
var models_path = __dirname + '/app/models'; var models_path = __dirname + '/app/models';
var walk = function(path) { var walk = function(path) {
fs.readdirSync(path).forEach(function(file) { fs.readdirSync(path).forEach(function(file) {
var newPath = path + '/' + file; var newPath = path + '/' + file;
var stat = fs.statSync(newPath); var stat = fs.statSync(newPath);
if (stat.isFile()) { if (stat.isFile()) {
if (/(.*)\.(js$|coffee$)/.test(file)) { if (/(.*)\.(js$|coffee$)/.test(file)) {
require(newPath); require(newPath);
} }
} else if (stat.isDirectory()) { } else if (stat.isDirectory()) {
walk(newPath); walk(newPath);
} }
}); });
}; };
walk(models_path); walk(models_path);