aboutsummaryrefslogtreecommitdiffstats
path: root/server.js
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2021-11-11 06:12:32 +0000
committerterminaldweller <thabogre@gmail.com>2021-11-11 06:12:32 +0000
commit00301734db0e9492ac636f8e99db65b34542224d (patch)
tree142b7e8b9293b5536d1f7e5f5a717073eac37c1f /server.js
parenthttp2 WIP (diff)
downloadblog-00301734db0e9492ac636f8e99db65b34542224d.tar.gz
blog-00301734db0e9492ac636f8e99db65b34542224d.zip
changes the layout of the bloghttps
Diffstat (limited to 'server.js')
-rwxr-xr-xserver.js48
1 files changed, 38 insertions, 10 deletions
diff --git a/server.js b/server.js
index 0c245a3..94a6082 100755
--- a/server.js
+++ b/server.js
@@ -23,6 +23,7 @@ const spdy = require("spdy");
const app = express();
app.use(express.static(path.join(__dirname, "css")));
+app.use(express.static(path.join(__dirname, "static")));
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "ejs");
app.engine("ejs", require("ejs").__express);
@@ -60,6 +61,21 @@ app.get("/health", (req, res) => {
res.send(response);
});
+app.get("/about", (req, res) => {
+ res.type("text/html");
+ res.sendFile(path.join(__dirname, "static/about.html"));
+});
+
+app.get("/archive", (req, res) => {
+ res.type("text/html");
+ res.render("archive", {
+ cache: true,
+ data: {
+ mds: fs.readdirSync(path.join(__dirname, "mds"), "utf-8"),
+ },
+ });
+});
+
app.get("/robots.txt", (req, res) => {
res.type("text/plain");
let robots_txt = "Sitemap: http://blog.terminaldweller.com\n";
@@ -84,7 +100,7 @@ async function enumerateDir() {
return await fs.readdirSync(path.join(__dirname, "mds"));
}
-app.use(sitemap(enumerateDir, "http://blog.terminaldweller.com"));
+app.use(sitemap(enumerateDir, "https://blog.terminaldweller.com"));
app.use((req, res) => {
return res.status(404).send({ message: "Path" + req.url + "not found!" });
@@ -94,12 +110,24 @@ app.use((err, req, res) => {
return res.status(500).send({ error: err });
});
-spdy
- .createServer(
- {
- key: fs.readFileSync("/certs/privkey1.pem", "utf-8"),
- cert: fs.readFileSync("/certs/fullchain1.pem", "utf-8"),
- },
- app
- )
- .listen(9000);
+if (process.env.SERVER_DEPLOYMENT_TYPE == "deployment") {
+ spdy
+ .createServer(
+ {
+ key: fs.readFileSync("/certs/privkey1.pem", "utf-8"),
+ cert: fs.readFileSync("/certs/fullchain1.pem", "utf-8"),
+ },
+ app
+ )
+ .listen(process.env.SERVER_LISTEN_PORT || 9000);
+} else if (process.env.SERVER_DEPLOYMENT_TYPE == "test") {
+ spdy
+ .createServer(
+ {
+ key: fs.readFileSync("/certs/server.key", "utf-8"),
+ cert: fs.readFileSync("/certs/server.cert", "utf-8"),
+ },
+ app
+ )
+ .listen(process.env.SERVER_LISTEN_PORT || 9000);
+}