-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathserver.js
executable file
·48 lines (31 loc) · 979 Bytes
/
server.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
'use strict';
/**
* Module dependencies.
*/
var express = require('express'),
walker = require('./config/walker');
/**
* Main application entry file.
* Please note that the order of loading is important.
*/
// Load configurations
// Set the node enviornment variable if not set before
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
// Initializing system variables
var config = require('./config/config'),
mongoose = require('mongoose');
// Bootstrap db connection
var db = mongoose.connect(config.db);
// Bootstrap models
walker.modelWalker(__dirname + '/app/models');
var app = express();
// Express settings
require('./config/express')(app, db);
// Bootstrap routes
walker.routeWalker(__dirname + '/app/routes', app);
// Start the app by listening on <port>
var port = process.env.PORT || config.port;
app.listen(port);
console.log('Express app started on port ' + port);
// Expose app
exports = module.exports = app;