using two spaces for tabs
This commit is contained in:
parent
79e6cdfffd
commit
e33ee06cc6
|
@ -1,5 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
exports.render = function(req, res) {
|
||||
res.render('index');
|
||||
res.render('index');
|
||||
};
|
||||
|
|
|
@ -5,5 +5,5 @@ var _ = require('lodash');
|
|||
// Load app configuration
|
||||
|
||||
module.exports = _.extend(
|
||||
require(__dirname + '/../config/env/all.js'),
|
||||
require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.js') || {});
|
||||
require(__dirname + '/../config/env/all.js'),
|
||||
require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.js') || {});
|
||||
|
|
|
@ -4,7 +4,7 @@ var path = require('path'),
|
|||
rootPath = path.normalize(__dirname + '/../..');
|
||||
|
||||
module.exports = {
|
||||
root: rootPath,
|
||||
port: process.env.PORT || 3000,
|
||||
db: process.env.MONGOHQ_URL
|
||||
root: rootPath,
|
||||
port: process.env.PORT || 3000,
|
||||
db: process.env.MONGOHQ_URL
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
db: "mongodb://localhost/mystery-dev",
|
||||
app: {
|
||||
name: "Mystery - Development"
|
||||
}
|
||||
db: "mongodb://localhost/mystery-dev",
|
||||
app: {
|
||||
name: "Mystery - Development"
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
db: "mongodb://localhost/mystery",
|
||||
app: {
|
||||
name: "Mystery - Production"
|
||||
}
|
||||
db: "mongodb://localhost/mystery",
|
||||
app: {
|
||||
name: "Mystery - Production"
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
db: "mongodb://localhost/mystery-test",
|
||||
port: 3001,
|
||||
app: {
|
||||
name: "Mystery - Test"
|
||||
}
|
||||
db: "mongodb://localhost/mystery-test",
|
||||
port: 3001,
|
||||
app: {
|
||||
name: "Mystery - Test"
|
||||
}
|
||||
}
|
|
@ -4,66 +4,66 @@
|
|||
* Module dependencies.
|
||||
*/
|
||||
var express = require('express'),
|
||||
config = require('./config');
|
||||
config = require('./config');
|
||||
|
||||
module.exports = function(app, passport, db) {
|
||||
app.set('showStackError', true);
|
||||
app.set('showStackError', true);
|
||||
|
||||
//Prettify HTML
|
||||
app.locals.pretty = true;
|
||||
//Prettify HTML
|
||||
app.locals.pretty = true;
|
||||
|
||||
//Should be placed before express.static
|
||||
app.use(express.compress({
|
||||
filter: function(req, res) {
|
||||
return (/json|text|javascript|css/).test(res.getHeader('Content-Type'));
|
||||
},
|
||||
level: 9
|
||||
}));
|
||||
//Should be placed before express.static
|
||||
app.use(express.compress({
|
||||
filter: function(req, res) {
|
||||
return (/json|text|javascript|css/).test(res.getHeader('Content-Type'));
|
||||
},
|
||||
level: 9
|
||||
}));
|
||||
|
||||
//Set views path, template engine and default layout
|
||||
app.set('views', config.root + '/app/views');
|
||||
app.set('view engine', 'jade');
|
||||
//Set views path, template engine and default layout
|
||||
app.set('views', config.root + '/app/views');
|
||||
app.set('view engine', 'jade');
|
||||
|
||||
//Enable jsonp
|
||||
app.enable("jsonp callback");
|
||||
//Enable jsonp
|
||||
app.enable("jsonp callback");
|
||||
|
||||
app.configure(function() {
|
||||
//cookieParser should be above session
|
||||
app.use(express.cookieParser());
|
||||
app.configure(function() {
|
||||
//cookieParser should be above session
|
||||
app.use(express.cookieParser());
|
||||
|
||||
// request body parsing middleware should be above methodOverride
|
||||
app.use(express.urlencoded());
|
||||
app.use(express.json());
|
||||
app.use(express.methodOverride());
|
||||
// request body parsing middleware should be above methodOverride
|
||||
app.use(express.urlencoded());
|
||||
app.use(express.json());
|
||||
app.use(express.methodOverride());
|
||||
|
||||
//routes should be at the last
|
||||
app.use(app.router);
|
||||
//routes should be at the last
|
||||
app.use(app.router);
|
||||
|
||||
//Setting the fav icon and static folder
|
||||
app.use(express.favicon());
|
||||
app.use(express.static(config.root + '/public'));
|
||||
//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.
|
||||
app.use(function(err, req, res, next) {
|
||||
//Treat as 404
|
||||
if (~err.message.indexOf('not found')) return next();
|
||||
//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.
|
||||
app.use(function(err, req, res, next) {
|
||||
//Treat as 404
|
||||
if (~err.message.indexOf('not found')) return next();
|
||||
|
||||
//Log it
|
||||
console.error(err.stack);
|
||||
|
||||
//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'
|
||||
});
|
||||
});
|
||||
//Log it
|
||||
console.error(err.stack);
|
||||
|
||||
//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'
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
};
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
module.exports = function(app) {
|
||||
|
||||
//Home route
|
||||
var index = require('../app/controllers/index');
|
||||
app.get('/', index.render);
|
||||
//Home route
|
||||
var index = require('../app/controllers/index');
|
||||
app.get('/', index.render);
|
||||
|
||||
};
|
||||
|
|
26
server.js
26
server.js
|
@ -4,7 +4,7 @@
|
|||
* Module dependencies.
|
||||
*/
|
||||
var express = require('express'),
|
||||
fs = require('fs');
|
||||
fs = require('fs');
|
||||
|
||||
/**
|
||||
* Main application entry file.
|
||||
|
@ -16,7 +16,7 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|||
|
||||
//Initializing system variables
|
||||
var config = require('./config/config'),
|
||||
mongoose = require('mongoose');
|
||||
mongoose = require('mongoose');
|
||||
|
||||
//Bootstrap db connection
|
||||
var db = mongoose.connect(config.db);
|
||||
|
@ -24,17 +24,17 @@ var db = mongoose.connect(config.db);
|
|||
//Bootstrap models
|
||||
var models_path = __dirname + '/app/models';
|
||||
var walk = function(path) {
|
||||
fs.readdirSync(path).forEach(function(file) {
|
||||
var newPath = path + '/' + file;
|
||||
var stat = fs.statSync(newPath);
|
||||
if (stat.isFile()) {
|
||||
if (/(.*)\.(js$|coffee$)/.test(file)) {
|
||||
require(newPath);
|
||||
}
|
||||
} else if (stat.isDirectory()) {
|
||||
walk(newPath);
|
||||
}
|
||||
});
|
||||
fs.readdirSync(path).forEach(function(file) {
|
||||
var newPath = path + '/' + file;
|
||||
var stat = fs.statSync(newPath);
|
||||
if (stat.isFile()) {
|
||||
if (/(.*)\.(js$|coffee$)/.test(file)) {
|
||||
require(newPath);
|
||||
}
|
||||
} else if (stat.isDirectory()) {
|
||||
walk(newPath);
|
||||
}
|
||||
});
|
||||
};
|
||||
walk(models_path);
|
||||
|
||||
|
|
Loading…
Reference in New Issue