-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver.js
executable file
·52 lines (43 loc) · 1.13 KB
/
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
49
50
51
52
'use strict';
/**
* Lets set the environment variable for heroku
* This file is not checked into source control
*/
const envs_exist = require('fs').existsSync('./config/env/heroku.js');
if (envs_exist) {
require('./config/env/heroku.js')();
}
// Init the new relic application
require('newrelic');
/**
* Module dependencies.
*/
const init = require('./config/init')(),
config = require('./config/config'),
mongoose = require('mongoose'),
chalk = require('chalk');
/**
* Main application entry file.
* Please note that the order of loading is important.
*/
// Bootstrap db connection
mongoose.connect(config.db,
{
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
},
function (err) {
if (err) {
console.error(chalk.red('Could not connect to MongoDB!'));
console.log(chalk.red(err));
}
});
// Init the express application
const app = require('./config/express')(mongoose);
// Start the app by listening on <port>
app.listen(config.port);
// Expose app
exports = module.exports = app;
// Logging initialization
console.log('MEAN.JS application started on port ' + config.port);