From 13859b2965e68f7c72ce26e7e9fb270ebe45f837 Mon Sep 17 00:00:00 2001 From: "Glitch (hello-express)" Date: Sun, 3 Nov 2019 17:45:01 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=B6=F0=9F=98=BB=20Checkpoint=20./serve?= =?UTF-8?q?r.js:933874/5449?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/server.js b/server.js index ecd3748..f5f44d2 100644 --- a/server.js +++ b/server.js @@ -13,15 +13,12 @@ try { const express = require("express"); const app = express(); -// http://expressjs.com/en/starter/static-files.html app.use(express.static("public")); -// http://expressjs.com/en/starter/basic-routing.html app.get("/", (req, res) => { res.sendFile(__dirname + "/views/index.html"); }); -// http://expressjs.com/en/starter/basic-routing.html app.get("/img", (req, res) => { if (fuzIsOpen && new Date() - 2 * 60 * 1000 < lastSeen) { return res.sendFile(__dirname + "/views/open.svg"); // https://www.flaticon.com/free-icon/open_1234189 @@ -37,7 +34,6 @@ app.get("/api", (req, res) => { res.send({ fuzIsOpen, lastSeen }); }); -// http://expressjs.com/en/starter/basic-routing.html app.get("/status", (req, res) => { // http basic auth handling without 3rd-party lib https://stackoverflow.com/a/33905671 const auth = { @@ -73,10 +69,12 @@ const listener = app.listen(process.env.PORT, function() { console.log("Your app is listening on port " + listener.address().port); }); -process.on("SIGTERM", function() { - console.log("SIGTERM received, sending SOS to Resurrect..."); - require("https").get( - "https://resurrect.glitch.me/" + process.env.PROJECT_DOMAIN + "", - process.exit - ); -}); +if (process.env.PROJECT_DOMAIN != "") { + process.on("SIGTERM", function() { + console.log("SIGTERM received, sending SOS to Resurrect..."); + require("https").get( + "https://resurrect.glitch.me/" + process.env.PROJECT_DOMAIN + "", + process.exit + ); + }); +}