-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (34 loc) · 1.07 KB
/
app.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
39
40
const express = require('express')
const mongoose = require('mongoose')
const dotenv = require('dotenv')
const hotelRouter = require('./routes/hotels_route')
const roomRouter = require("./routes/rooms_route")
const staffRouter = require("./routes/staff_route")
const userRouter = require("./routes/user_route")
const adminRouter = require("./routes/admin_route")
const bookingRouter = require("./routes/room_booking_route")
const path = require("path")
const cors = require('cors')
dotenv.config();
var app = express();
const connect = async ()=>{
try{
await mongoose.connect(process.env.DB_CONNECT);
console.log("db connected")
}
catch(err){
console.log(err);
}
}
app.use(cors({ Credentials: true, origin: "http://localhost:4200"}))
app.use('/uploads',express.static(path.join('uploads')));
app.use("/api/hotel",hotelRouter)
app.use("/api/admin",adminRouter)
app.use("/api/room",roomRouter)
app.use("/api/booking",bookingRouter)
app.use("/api/staff",staffRouter)
app.use("/api/user",userRouter)
app.listen(5000, ()=> {
connect()
console.log('server started')
})