-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (29 loc) · 885 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
const express = require("express");
const config = require("config");
const mongoose = require("mongoose");
const app = express();
const port = process.env.PORT || 8000;
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use("/homes", require("./routes/homes"));
app.use("/guests", require("./routes/users"));
// app.use("/hosts", require("./routes/hosts"));
app.use("/bookings", require("./routes/bookings"));
app.get("/", (req, res) => {
res.send(`
<h1> Airbnb Clone </h1>
`);
});
// DB Config
const uri = config.get("mongoURI");
// Connect to Mongo
mongoose
.connect(uri, {
useNewUrlParser: true,
useCreateIndex: true
}) // Adding new mongo url parser
.then(() => console.log("database connected!"))
.catch(err => console.log(err));
app.listen(port, () => {
console.log(`server started at http://localhost:${port}`);
});