-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
38 lines (29 loc) · 861 Bytes
/
app.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
//start with requiring express into our system.
const express = require("express");
//require mongoose into the system.
const mongoose = require("mongoose");
//require port number
const port = process.env.PORT || 3000;
//connect to heroku
const cors = require("cors");
//We will then set up our express app
const app = express();
//connect to the database online
const ONLINE_DB =
"mongodb+srv://Oluwaseun1998:[email protected]/praiseBookShop?retryWrites=true&w=majority";
mongoose
.connect(ONLINE_DB, {
useCreateIndex: true,
useFindAndModify: false,
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log(`Database is active`);
});
app.use(cors());
app.use(express.json());
app.use("/", require("./component/controller"));
app.listen(port, () => {
console.log(`port is listening`);
});