-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (29 loc) · 1.01 KB
/
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
35
36
const express = require("express");
const mongoose = require("mongoose");
const RestaurantRoute = require("./routes/restaurantRoute");
const MenuRoute = require("./routes/menuRoute");
const app = express();
require('dotenv').config();
const cors = require('cors');
app.use(express.json({ limit: '50mb' }));
app.use(express.urlencoded({ limit: '50mb', extended: true }));
app.use(cors());
app.use("/cms/restaurant", RestaurantRoute);
app.use('/cms/restaurant/menu', MenuRoute);
app.use(express.static('public'));
// mongodb+srv://cms:[email protected]/cmsdb
const connectAPP = process.env.MONGODB_URL;
mongoose
.connect(connectAPP, {
useNewUrlParser: true,
useUnifiedTopology: true,
}).then(() => {
let port = process.env.PORT;
if (port == null || port == "") {
port = 8000;
}
console.log("successfully listening on port after connection", port)
app.listen(port);
}).catch((e) => {
console.log("error", e.message);
})