-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (28 loc) · 777 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
32
33
34
// Enviroment Variables
require('dotenv').config();
// Routes
const routes = require('./Routes/Router')
// Dependencies
const bodyParser = require('body-parser');
const express = require('express');
const cors = require('cors');
const app = express();
const mongoose = require('mongoose');
mongoose.set({
"strictQuery": false
})
// Port
const port = process.env.PORT;
// Used Packages in Express App
app.use(cors());
app.use(bodyParser.json());
app.use(routes);
app.listen(port, () =>
console.log(`Server is listening at http://localhost:${port}`)
);
// Database Connection
dbConnection().then(() => console.log("mongodb is connected")).catch(err => console.log(err));
async function dbConnection() {
mongoose.connect(process.env.MONGO_URL);
}
module.exports = app