forked from linnovate/mean
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
executable file
·36 lines (29 loc) · 1.02 KB
/
server.js
File metadata and controls
executable file
·36 lines (29 loc) · 1.02 KB
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
'use strict';
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
passport = require('passport'),
logger = require('mean-logger');
/**
* Main application entry file.
* Please note that the order of loading is important.
*/
// Initializing system variables
var config = require('./server/config/config');
var app = {};
var db = mongoose.connect(config.db, function(err) {
if (err) {
console.error('Error:', err.message);
return console.error('**Could not connect to MongoDB. Please ensure mongod is running and restart MEAN app.**');
}
// Bootstrap Models, Dependencies, Routes and the app as an express app
app = require('./server/config/system/bootstrap')(passport, db);
// Start the app by listening on <port>, optional hostname
app.listen(config.port, config.hostname);
console.log('MEAN app started on port ' + config.port + ' (' + process.env.NODE_ENV + ')');
// Initializing logger
logger.init(app, passport, mongoose);
});
// Expose app
exports = module.exports = app;