-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (25 loc) · 988 Bytes
/
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
const express = require("express");
const bodyParser = require("body-parser");
const commonHeaders = require("./middleware/common-headers");
const authRoutes = require("./routes/auth-routes");
const userRoutes = require("./routes/user-routes");
const eventRoutes = require("./routes/event-routes");
const passport = require("passport");
const db = require("./config/db");
const HttpError = require("./models/http-error");
const app = express();
app.use(bodyParser.json()); //parse request body
app.use(commonHeaders); //add common headers like CORS
app.use(passport.initialize()); //init passport for fb authentication
app.use(passport.session());
require("./config/passport"); //passport config for facebook authentication
app.use("/api/v1/auth", authRoutes);
app.use("/api/v1/event", eventRoutes);
app.use("/api/v1/user", userRoutes);
db.connect()
.then(() => {
app.listen(process.env.PORT || 5000);
})
.catch((err) => {
throw new HttpError(err.message, 500);
});