-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
42 lines (31 loc) · 1.17 KB
/
index.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
const fs = require('fs')
const https = require('https');
const path = require('path')
const express = require('express')
const env = require('dotenv')
const glob = require('glob')
const mongoose = require('mongoose')
const cors = require('cors')
const bodyParser = require('body-parser');
env.config()
const config = require('./config')
mongoose.connect(config.db_url)
.then(() => console.log('MongoDB Connected!'));
const app = express()
app.use(cors())
app.use(bodyParser.urlencoded({ extended: false, limit: "5mb" })); // Parses urlencoded bodies
app.use(bodyParser.json({ limit: "5mb" })); // Send JSON responses
glob.sync('./models/**/*.js').forEach(model => {
require('./' + model)
})
const passportService = require(path.resolve('./utils/passport')); // don't remove this line though this variable is not used.
glob.sync('./routes/**/*.js').forEach(router => {
require('./' + router)(app)
})
// app.use(express.static(path.join(__dirname, "build")));
// app.get("*", function (req, res) {
// res.sendFile(path.join(__dirname, "build", "index.html"));
// });
app.listen(process.env.PORT, () => {
console.log(`Serever is runing at port ${process.env.PORT}`);
});