-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (29 loc) · 840 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
36
37
38
39
40
const dotenv = require("dotenv").config();
const express = require("express");
const colors = require("colors");
const cors = require("cors");
const req = require("express/lib/request");
const res = require("express/lib/response");
const mongoose = require("mongoose");
const app = express();
const PORT = process.env.SERVER_PORT;
// Mongo DB Connection
// STARTS HERE
const DB = process.env.DATABASE;
mongoose
.connect(DB)
.then(() => {
console.log(`MongoDB connected`);
})
.catch((err) => console.log(err));
// Mongo DB Connection
// ENDS HERE
// MIDDLEWARES
app.use(cors());
app.use(express.json({ extended: false }));
// Linking router files to make our route easy
app.use(require("./router/routes"));
// LISTEN REQUEST
app.listen(PORT, function () {
console.log(`Server started on port ${PORT}`.red.bold);
});