-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (30 loc) · 851 Bytes
/
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
const express = require("express");
const app = express();
const morgan = require("morgan");
app.use(morgan("combined"));
const port = process.env.PORT || 5000; //allows heroku to specify its own port
const hbs = require("hbs");
app.set("view engine", "hbs");
const bodyParser = require("body-parser");
app.use(
bodyParser.urlencoded({
extended: true
})
);
app.use(bodyParser.json());
const cookieParser = require("cookie-parser");
app.use(cookieParser());
const jwt = require("express-jwt");
app.use(
jwt({
secret: "bodacious",
credentialsRequired: false,
requestProperty: "jwt",
getToken: req => req.cookies.jwt
})
);
app.use("/", express.static("./frontend/build"));
app.use("/api", require("./routes/api"));
app.listen(port, () => {
console.log(`listening on port ${port}`);
});