-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (53 loc) · 1.6 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const express = require("express")
const bodyParser = require("body-parser")
const session = require("express-session")
const mongoose = require("mongoose")
const passport = require("passport")
const AuthRoute = require('./routes/auth').router
const UserRoute = require("./routes/user").router
const BookingRoute = require("./routes/bookings").router
const PaymentRoute = require("./routes/payment").router
const OrderRoute = require("./routes/order").router
const cookieParser = require('cookie-parser');
const cors = require("cors")
const app = express()
app.use(cors());
app.set("trust proxy", 1)
require('dotenv').config()
require('./utils/passport-setup')
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended : true}))
app.use(bodyParser.json());
const MongoStore = require('connect-mongo')(session);
app.use(
session({
secret: 'laundryhub',
resave: false,
saveUninitialized: false,
store: new MongoStore({mongooseConnection : mongoose.connection})
})
);
//Google auth
app.use(passport.initialize())
app.use(passport.session())
//routes
app.use("/auth", AuthRoute)
app.use("/user", UserRoute)
app.use("/booking", BookingRoute)
app.use("/payment", PaymentRoute)
app.use("/order", OrderRoute)
const PORT = process.env.PORT || 5000
const MONGO_URI = process.env.MONGO_URI
console.log(MONGO_URI)
mongoose.connect(MONGO_URI, {
useNewUrlParser: true,
}).then(() => {
app.listen(PORT , ()=>{
console.log(`listening on port ${PORT}`)
})
}).catch((err) => {
console.log(err.message + "Errorrrrrrr")
})
app.get('/', (req, res) => {
res.send('Hello World!');
});