-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
35 lines (29 loc) · 881 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
31
32
33
34
35
const dotenv = require("dotenv");
const http = require("http");
const mongoose = require("mongoose");
const app = require("./app");
const { socketSetup } = require("./socketSetup");
const config = require("./utils/config");
const server = http.createServer(app);
socketSetup(server);
dotenv.config();
console.log("Starting app..");
//console.log("Waiting for connection to MongoDB");
mongoose
.connect(config.MONGODB_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false,
})
.then(() => {
console.log("Connected to MongoDB!");
console.log("Starting webserver..");
server.listen(config.PORT, () => {
console.log(`Server is running on port ${config.PORT}`);
});
})
.catch(() => {
console.log("Could not connect to MongoDB server! Shutting down...");
process.exit(1);
});