From 0711674a794995dfdb5a5736dd90ec26dba09adc Mon Sep 17 00:00:00 2001 From: JayWll Date: Sat, 11 Apr 2020 13:07:57 -0600 Subject: [PATCH] Adjust all functions to use factored out database definition --- nodeapp/app.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nodeapp/app.js b/nodeapp/app.js index 007c5be..a8c273f 100644 --- a/nodeapp/app.js +++ b/nodeapp/app.js @@ -15,7 +15,7 @@ app.get('/newreading', (req, res) => { // Filter out requests that don't include the secret key, or don't contain the required data if (req.query.s != process.env.SECRET || !RegExp('^\\d*$').test(req.query.v)) return res.status(400).send('Bad Request').end(); - Readings.create({ timestamp: new Date(), reading: req.query.v }); + db.Readings.create({ timestamp: new Date(), reading: req.query.v }); res.status(200).send('Reading received: ' + req.query.v).end(); }); @@ -50,7 +50,7 @@ app.get('/exportall', (req, res) => { return res.status(401).send('Authorization header not found').end(); } - Readings.findAll().then((result) => { + db.Readings.findAll().then((result) => { res.status(200).send(result).end(); }) }) @@ -67,7 +67,7 @@ app.get('/cleanup', (req, res) => { before.setMinutes(0); before.setSeconds(0); - Readings.destroy({ + db.Readings.destroy({ where: { timestamp: { [db.Op.lt]: before @@ -81,6 +81,5 @@ app.get('/cleanup', (req, res) => { // listen for requests :) const listener = app.listen(process.env.PORT || 4200, function() { - console.log(process.env.DB_USER) console.log("Your app is listening on port " + listener.address().port); });