From 0197ccef7653ce5dce206b511bd55a3d756c909d Mon Sep 17 00:00:00 2001 From: Quentin ANIERE Date: Thu, 14 Apr 2022 15:57:54 +0200 Subject: [PATCH] Add clear page --- index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.js b/index.js index 297a0a1..8887a8e 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,8 @@ const fs = require("fs"); const https = require("https"); const express = require("express"); const socketio = require("socket.io"); +const basicAuth = require("express-basic-auth"); + const app = express(); const https_options = { @@ -91,6 +93,13 @@ io.on("connection", (client) => { app.use(express.static("src")); +app.get("/clear", basicAuth({users:{"quentin": "BlanquerCaca89"}, challenge: true}), (req, res) => { + messagesHistory = []; + res.send("message history was cleared"); + log("Admin cleared messages history"); + io.sockets.emit("refresh"); +}); + app.listen(80, () => { log("Web server started on port 80") });