From 840560b793544e089d92885f2ab75c1ddf83d051 Mon Sep 17 00:00:00 2001 From: "Glitch (hello-express)" Date: Sun, 3 Nov 2019 11:45:01 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=95=B5=E2=9C=A8=20Checkpoint=20./server.j?= =?UTF-8?q?s:933874/5595?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 1656e2e..3be427f 100644 --- a/server.js +++ b/server.js @@ -1,4 +1,13 @@ var fuzIsOpen = false; +var lastSeen = new Date("1970-01-01"); + +const fs = require("fs"); +const db = "./.data/data.json"; + +try { + var content = fs.readFileSync(db, "utf8"); + fuzIsOpen = JSON.parse(content)[""] +} catch (err) {} const express = require("express"); const app = express(); @@ -14,6 +23,8 @@ app.get("/", (req, res) => { // http://expressjs.com/en/starter/basic-routing.html app.get("/img", (req, res) => { res.sendFile(__dirname + "/views/index.html"); + if (fuzIsOpen) { + } }); // http://expressjs.com/en/starter/basic-routing.html @@ -31,7 +42,10 @@ const listener = app.listen(process.env.PORT, function() { console.log("Your app is listening on port " + listener.address().port); }); -process.on("SIGTERM", function () { +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) -}); \ No newline at end of file + require("https").get( + "https://resurrect.glitch.me/" + process.env.PROJECT_DOMAIN + "", + process.exit + ); +});