forked from ValeryShvyndzikau/angular-spa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
68 lines (54 loc) · 1.68 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* Module dependencies.
*/
var config = require('./config.json');
var env_dev = 'Development';
var env_prod = 'Production';
var node_env = process.env.NODE_ENV || env_dev;
var node_user_id = process.env.NODE_USER_ID || null;
var express = require('express');
var path = require('path');
var app = express();
var mongoose = require('mongoose');
// Init mongoose
mongoose.connect('mongodb://' + config.mongoose.user + ':' + config.mongoose.pass +
'@' + config.mongoose.host + ':' + config.mongoose.port + '/' + config.mongoose.database);
// Configuration
app.configure(function () {
app.locals.basedir = __dirname;
app.set('views', __dirname + '/' + config.angular.rootDirectory);
app.set('view engine', 'jade');
app.set('view options', {
layout: true
});
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/' + config.angular.rootDirectory));
app.locals.basedir = path.join(app.get('views'));
app.envSettings = {
environmentType: node_env,
user: node_user_id
};
});
app.configure('development', function () {
app.use(express.errorHandler({dumpExceptions: true, showStack: true}));
});
app.configure('production', function () {
app.use(express.errorHandler());
});
app.listen(config.application.port, function () {
console.log("Express server listening on port %d in %s mode", config.application.port, app.settings.env);
});
// Init RestModules loader
var API = new require('./rest-modules/api')(app, mongoose);
API.initRestModules([
'article',
'publication',
'tags',
'user',
'role',
'index',
'admin',
'search'
]);