-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (41 loc) · 1.34 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const express = require('express')
const mongoose = require('mongoose')
const cors = require('cors')
require('dotenv').config();
const app = express()
// Regular middleware
app.use(express.json());
app.use(cors());
// routers
const landDetailsRouter = require('./routes/landDetails')
app.use('/landDetails', landDetailsRouter)
const SellingLandRouter = require('./routes/SellingLand')
app.use('/SellingLand', SellingLandRouter)
const userDetailsRouter = require('./routes/user')
app.use('/user', userDetailsRouter)
const verifyOtpRouter = require('./routes/verifyOtp')
app.use('/otp', verifyOtpRouter)
const purchaseRequestRouter = require('./routes/purchaseRequest')
app.use('/purchaseRequest', purchaseRequestRouter)
const auctionRouter = require('./routes/auction')
app.use('/auction', auctionRouter)
const getall = require('./routes/getall')
app.use('/getall', getall)
const chatDetails = require('./routes/chatDetails')
app.use('/chats', chatDetails)
// PORT
const port = process.env.PORT || 8000;
// MONGODB Connect
mongoose.connect(process.env.MONGODB_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(console.log(`DB connected successfully`))
.catch(error =>{
console.log(`DB connection failed`);
console.log(error);
process.exit(1);
})
app.listen(port, () =>{
console.log(`Server is running on port: ${port}`);
});