forked from MidknightRyk/HydroHomies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
43 lines (37 loc) · 1.09 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
var express = require("express");
var app = express();
var bodyParser = require("body-parser");
var session = require("cookie-parser");
var flash = require("express-flash");
var path = require("path");
app.use(bodyParser.json());
app.use(
bodyParser.urlencoded({
extended: true
})
);
app.use(express.static(path.join(__dirname, "front-end/build")));
app.use(session());
// Database setup
require("./models/db.js");
require("./config/passport.js");
// Passport setup
var passport = require("passport");
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
const cors = require("cors");
app.use(cors());
var routes = require("./routes/routes.js");
app.use("/", routes);
// The 'catchall' handler: for any request that doesn't
// match one above, send back React's index.html file.
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname + "/front-end/build/index.html"));
});
// Using port 9000 to avoid conflict with front-end
const PORT = process.env.PORT || 9000;
// Start the server
app.listen(PORT, function() {
console.log(`Express listening on port ${PORT}`);
});