-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (25 loc) · 894 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
31
const express = require("express");
const app = express();
const cors = require("cors");
require("dotenv").config();
const dbConnectFunc = require("./db/dbIntegration");
const publicRoute = require("./routes/public");
const privateRoute = require("./routes/private");
const adminRoute = require("./routes/admin");
const AuthCheck = require("./middlewares/AuthCheck");
const AdminCheck = require("./middlewares/AdminCheck");
app.use(cors());
app.use(express.json());
app.get("/", (req, res) => {
res.send("Welcome to equipment-lender Application");
});
app.use("/api/public", publicRoute);
app.use("/api/private", AuthCheck, privateRoute);
app.use("/api/admin", AuthCheck, AdminCheck, adminRoute);
dbConnectFunc()
.then(() => {
app.listen(process.env.PORT || 4080, () => {
console.log("Server Started");
});
})
.catch((e) => console.log(e.message, " ERR-index.js"));