-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
38 lines (26 loc) · 1.07 KB
/
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
36
37
38
const express = require('express');
const mongoose = require('mongoose');
const authRoute = require("./routes/authRoute")
const agentRoute = require("./routes/agentRoute")
const customerRoute = require("./routes/customerRouter")
const adminRoute = require("./routes/adminRoute")
const {checkPermission} = require("./middleware/checkPermission")
const cors = require('cors')
const app = express();
app.use(cors())
app.use(express.static('public'));
app.use(express.json());
const PORT = 9000;
const dbURI = 'mongodb+srv://ally:Asd@1234@cluster0.e694a.mongodb.net/red-carpet?retryWrites=true&w=majority';
mongoose.connect(dbURI, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex:true })
.then((result) => {
app.listen(PORT,() => {
console.log("Application Started in Port "+ PORT)
})
})
.catch((err) => console.log(err));
// ROUTES
app.use("/api/auth",authRoute);
app.use("/api/agent/",checkPermission("AGENT"),agentRoute);
app.use("/api/customer",checkPermission("CUSTOMER"),customerRoute)
app.use("/api/admin",checkPermission("ADMIN"),adminRoute)