-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (26 loc) · 884 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
require("dotenv").config();
const cors = require("cors");
const express = require("express");
const app = express();
const mongoose = require("mongoose");
const index = require("./routes/index")
const user = require("./routes/users")
const recipeOrder = require("./routes/recipeOrder")
//connect db
mongoose.connect(process.env.MONGO_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
});
mongoose.set("useFindAndModify", false);
mongoose.set("useCreateIndex", true);
const db = mongoose.connection;
db.on("error", (error) => console.error(error));
db.once("open", () => console.log("connected to database"));
// app.use(bodyParser());
app.use(cors({ origin: "*" }));
app.use(express.json());
app.use("/", index);
app.use("/user",user)
app.use("/order",recipeOrder)
app.listen(process.env.PORT || 3000, () => console.log("server started"));