-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
68 lines (63 loc) · 2.02 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
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
let mongoose = require("mongoose");
require("dotenv").config();
let express = require("express");
let cors = require("cors");
let app = express();
const corsOptions = {
origin: "*",
};
app.use(
express.urlencoded({
extended: true,
})
);
app.use(express.json({ limit: "10mb" }));
app.use(cors(corsOptions));
// connect to db
const username = process.env.WP_USERNAME;
const password = process.env.WP_PASSWORD;
const cluster = process.env.WP_CLUSTER;
const dbname = process.env.WP_DATABASE;
const uri = `mongodb+srv://${username}:${password}@${cluster}.mongodb.net/${dbname}?retryWrites=true&w=majority`;
mongoose
.connect(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
serverSelectionTimeoutMS: 5000,
})
.then(() => {
console.log("Successfully connected to database");
})
.catch((err) => console.log(err));
// mongoose.set('debug', true);
//end
const userRoute = require("./routes/user");
const membershipRoute = require("./routes/membership");
// const broadcastRoute = require("./routes/broadcastRoutes");
const facilitiesRoute = require("./routes/facilities");
const reservationsRoute = require("./routes/reservations");
const searchFacility = require("./routes/search");
const stripeRoute = require("./routes/stripe");
const merchandiseRoute = require("./routes/merchandise");
const blogRoute = require("./routes/blog");
const eventRouter = require('./routes/events');
const eventBookingRouter = require('./routes/eventBookings');
const rewardsRoute = require("./routes/rewards");
const couponsRoute = require("./routes/coupons");
app.use(userRoute);
app.use(rewardsRoute);
app.use(couponsRoute);
app.use(membershipRoute);
// app.use(broadcastRoute);
app.use("/facility", facilitiesRoute);
app.use("/reservation", reservationsRoute);
app.use("/search", searchFacility);
app.use(merchandiseRoute);
app.use(stripeRoute);
app.use('/blogs',blogRoute);
app.use('/events', eventRouter);
app.use('/event-bookings',eventBookingRouter);
app.use("/test", (req, res) => {
res.send("It works!'");
});
module.exports = app;