-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (23 loc) · 841 Bytes
/
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
/* eslint-disable no-console */
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const setupRoutesV1 = require('./routes/routes');
// eslint-disable-next-line new-cap
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
require('dotenv').config()
const MONGO_URI = process.env.DB_URI;
mongoose.set("useNewUrlParser", true);
mongoose.set("useCreateIndex", true);
mongoose.set("useUnifiedTopology", true);
// Creating mongodb connection
mongoose.connect(MONGO_URI).catch((err) => {
console.log("MongoDB connection error. Please make sure MongoDB is running. " + err);
process.exit(1);
});
setupRoutesV1(app);
const PORT = process.env.PORT;
// Running server
app.listen(PORT, console.log(`App is running on localhost:${PORT}`));