forked from quantum-jo/Currents2021-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (20 loc) · 739 Bytes
/
index.js
File metadata and controls
25 lines (20 loc) · 739 Bytes
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
const express = require('express');
const app = express();
var cors = require('cors');
const mongoose = require('mongoose');
require('dotenv').config();
const DB_config = require('./config/db.config');
mongoose.connect(`mongodb+srv://${DB_config.DB_username}:${DB_config.DB_password}@currents-21.4xyln.mongodb.net/${DB_config.DB_name}?retryWrites=true&w=majority`, {
useNewUrlParser: true,
useUnifiedTopology: true
})
.then(() => {
console.log("Connected to MongoDB");
})
.catch((err) => console.log(err));
const routes = require('./routes/index.router.js');
app.use(express.json());
app.use(cors());
app.use(routes);
let port = process.env.PORT || 3001;
app.listen(port, () => console.log(`Listening to port: ${port}`));