🎥🏑 Checkpoint
./server.js:7435365/533
This commit is contained in:
parent
06aad43cf3
commit
451d581782
@ -83,6 +83,9 @@ app.get('/getdata', (req, res) => {
|
|||||||
// Handle requests to /cleanup by deleting any data older than 90 days from the datastore
|
// Handle requests to /cleanup by deleting any data older than 90 days from the datastore
|
||||||
app.get('/cleanup', (req, res) => {
|
app.get('/cleanup', (req, res) => {
|
||||||
// SECURITY CHECK FOR THE CORRECT CRONJOB HEADER GOES HERE!!
|
// 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();
|
var before = new Date();
|
||||||
before.setDate(before.getDate()-91);
|
before.setDate(before.getDate()-91);
|
||||||
@ -96,8 +99,8 @@ app.get('/cleanup', (req, res) => {
|
|||||||
[Op.lt]: before
|
[Op.lt]: before
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).then((result) => {
|
}).then((numRows) => {
|
||||||
res.status(200).send(result).end();
|
res.status(200).send('Deleted rows: ' + numRows).end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user