From 451d581782d8a5f7d6b57a6891c30e0e85208158 Mon Sep 17 00:00:00 2001 From: "Glitch (hello-express)" Date: Fri, 20 Dec 2019 23:24:05 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A5=F0=9F=8F=91=20Checkpoint=20./serve?= =?UTF-8?q?r.js:7435365/533?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 27df625..07f94ec 100644 --- a/server.js +++ b/server.js @@ -83,6 +83,9 @@ app.get('/getdata', (req, res) => { // Handle requests to /cleanup by deleting any data older than 90 days from the datastore app.get('/cleanup', (req, res) => { // SECURITY CHECK FOR THE CORRECT CRONJOB HEADER GOES HERE!! + if (!req.headers['cleanup-key'] || req.headers['cleanup-key'] != process.env.SECRET) { + return res.status(401).send('Authorization header not found').end(); + } var before = new Date(); before.setDate(before.getDate()-91); @@ -96,8 +99,8 @@ app.get('/cleanup', (req, res) => { [Op.lt]: before } } - }).then((result) => { - res.status(200).send(result).end(); + }).then((numRows) => { + res.status(200).send('Deleted rows: ' + numRows).end(); }); });