-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
30 lines (26 loc) · 972 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
const express = require('express');
const fs = require('fs');
const passport = require('passport');
const env = process.env.NODE_ENV || 'development';
const config = require('./config/config')[env];
const auth = require('./config/middlewares/authorization');
const mongoose = require('mongoose');
const app = express();
const port = process.env.PORT || 3000;
mongoose.Promise = global.Promise;
mongoose.connect(config.db, {
keepAlive: true,
reconnectTries: Number.MAX_VALUE,
useMongoClient: true
});
//mongoose.connect('mongodb://root:volvo76@ds039078.mongolab.com:39078/ntwitter');
const models_path = __dirname+'/app/models';
fs.readdirSync(models_path).forEach(file => {
require(models_path+'/'+file);
});
require('./config/passport')(passport, config);
require('./config/express')(app, config, passport);
require('./config/routes')(app, passport, auth);
app.listen(port);
console.log('Express app started on port ' + port);
exports = module.exports = app;