-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
38 lines (31 loc) · 920 Bytes
/
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
const express = require('express');
const bodyParser = require('body-parser');
const fileUpload = require('express-fileupload');
const cors = require('cors');
const mongoose = require('mongoose');
var sockets = require('./server/loaders')
const router = require('./server/routes');
require('dotenv').config();
const PORT = process.env.PORT || 4000;
const app = express();
app.use(bodyParser.json());
app.use(cors());
app.use(fileUpload());
app.use('/', router);
mongoose.set('useFindAndModify', false);
mongoose.connect(
process.env.MONGODB_URI,
{
useNewUrlParser : true,
autoIndex: true
}
);
const connection = mongoose.connection;
connection.once('open', function(){
console.log("MongoDB connection established successfully.");
})
const server = app.listen(PORT, function(){
console.log("Server is running on port : ", PORT );
});
sockets.init(server);
module.exports = app;