-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (33 loc) · 1.2 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var express = require('express');
http = require('http'),
path = require('path'),
app = express();
config = require('nconf').argv().env().file('config', __dirname + '/configs/global.json');
global.express = express;
global.Middlewares = require(__dirname + '/middlewares');
global.Helpers = require(__dirname + '/helpers');
if (app.get('env') === 'development') {
app.use(express.errorHandler());
app.use(Middlewares.less());
config.file('local', __dirname + '/configs/local.json');
}
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
//global variables
global.config = config;
global.mongoose = require('mongoose');
global._ = require('underscore');
global.base_dir = __dirname;
global.app = app;
global.Models = require(__dirname + '/models')(config.get('DB'));
require(__dirname + '/controllers');
app.use(Middlewares.error_handler);
http.createServer(app).listen(config.get('PORT'), function(){
console.log('server listening on port ' + config.get('PORT'));
});