forked from jsonwebtoken/jsonwebtoken.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (30 loc) · 956 Bytes
/
Copy pathserver.js
File metadata and controls
37 lines (30 loc) · 956 Bytes
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
const express = require("express");
const enforce = require("express-sslify");
const languages = require("./libraries.json");
const app = express();
app.set("view engine", "pug");
app.set("views", __dirname + "/views/website");
if (process.env.NODE_ENV === "production") {
console.log("Redirecting to TLS endpoint.");
app.use(
enforce.HTTPS({
// Required for proper use under a reverse proxy (Heroku, etc.).
trustProtoHeader: true,
})
);
}
// app.use(fetchGithubStars);
app.use(express.static("dist/website"));
app.get("/", function(req, res) {
res.render("index", { languages: languages });
});
app.get("/introduction", function(req, res) {
res.render("introduction");
});
// Fallback for the homepage JWT handbook CTA A/B experiment we ran
app.get("/home", function(req, res) {
res.redirect("/");
});
app.listen(process.env.PORT || 3000, function() {
console.log("Started.");
});