From bea81bc280a03cc1bfe5a7d8f4ea0b2dd0d64e5a Mon Sep 17 00:00:00 2001 From: "Glitch (jasonsplant)" Date: Fri, 10 Apr 2020 17:51:31 +0000 Subject: [PATCH] Adding export endpoint to move live data to dev environment --- nodeapp/app.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nodeapp/app.js b/nodeapp/app.js index f52b00e..1f45a35 100644 --- a/nodeapp/app.js +++ b/nodeapp/app.js @@ -80,6 +80,18 @@ app.get('/getdata', (req, res) => { }) }); +// Export all data for development +app.get('/exportall', (req, res) => { + // Check that the expected key has been included with the web request + if (!req.headers['export-key'] || req.headers['export-key'] != process.env.SECRET) { + return res.status(401).send('Authorization header not found').end(); + } + + Readings.findAll().then((result) => { + res.status(200).send(result).end(); + }) +}) + // Handle requests to /cleanup by deleting any data older than 90 days from the datastore app.get('/cleanup', (req, res) => { if (!req.headers['cleanup-key'] || req.headers['cleanup-key'] != process.env.SECRET) {