From 713909baf190c25f6afec811cf6c174fbd0cb250 Mon Sep 17 00:00:00 2001 From: "Glitch (jasonsplant)" Date: Wed, 6 May 2020 02:20:43 +0000 Subject: [PATCH] Updating to redirect to correct domain --- nodeapp/app.js | 4 ++++ nodeapp/src/alert.js | 1 - nodeapp/src/db.js | 2 +- shrinkwrap.yaml | 54 +++++++++++++++++++++++++++----------------- 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/nodeapp/app.js b/nodeapp/app.js index 0180877..e721604 100644 --- a/nodeapp/app.js +++ b/nodeapp/app.js @@ -7,6 +7,10 @@ const app = express(); // Handle requests for the root page by serving the static index.html from the views folder app.get("/", function(req, res) { + if (!req.headers['x-real-host'] && req.headers.host.includes('glitch.me')) { + return res.redirect('https://www.jasonsplant.ml' + req.url); + } + res.sendFile(__dirname + "/views/index.html"); }); diff --git a/nodeapp/src/alert.js b/nodeapp/src/alert.js index e55424e..e1f2ea8 100644 --- a/nodeapp/src/alert.js +++ b/nodeapp/src/alert.js @@ -3,7 +3,6 @@ const twit = require('twit') require('dotenv').config({path: path.join(__dirname, '../../.env')}) const alert = (type) => { - console.log('Alert triggered for type: ' + type) var tweet = false switch(type) { diff --git a/nodeapp/src/db.js b/nodeapp/src/db.js index 7b54517..595b8f1 100644 --- a/nodeapp/src/db.js +++ b/nodeapp/src/db.js @@ -54,7 +54,7 @@ const Readings = sequelize.define('readings', { // If the first low reading was more than 4 days ago, send an alert if (lowtriggered > fourdays) { // Send alert that water is needed - message('needwater') + message('wantwater') // Flag that an alert has been sent Settings.update({ value: new Date().toISOString() }, { where: { key: 'alert' } }) diff --git a/shrinkwrap.yaml b/shrinkwrap.yaml index ecd6620..93bab76 100644 --- a/shrinkwrap.yaml +++ b/shrinkwrap.yaml @@ -1,27 +1,28 @@ dependencies: dotenv: 8.2.0 express: 4.17.1 - sequelize: 5.21.6 + sequelize: 5.21.7 sqlite3: 4.1.1 + twit: 2.2.11 packages: - /@types/node/13.11.1: + /@types/node/13.13.2: dev: false resolution: - integrity: sha512-eWQGP3qtxwL8FGneRrC5DwrJLGN4/dH1clNTuLfN81HCrxVtxRjygDTUoZJ5ASlDEeo0ppYFQjQIlXhtXpOn6g== + integrity: sha512-LB2R1Oyhpg8gu4SON/mfforE525+Hi/M1ineICEDftqNVTyFg1aRIeGuTvXAoWHc4nbrFncWtJgMmoyRvuGh7A== /abbrev/1.1.1: dev: false resolution: integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== /accepts/1.3.7: dependencies: - mime-types: 2.1.26 + mime-types: 2.1.27 negotiator: 0.6.2 dev: false engines: node: '>= 0.6' resolution: integrity: sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA== - /ajv/6.12.0: + /ajv/6.12.2: dependencies: fast-deep-equal: 3.1.1 fast-json-stable-stringify: 2.1.0 @@ -29,7 +30,7 @@ packages: uri-js: 4.2.2 dev: false resolution: - integrity: sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw== + integrity: sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ== /ansi-regex/2.1.1: dev: false engines: @@ -373,7 +374,7 @@ packages: dependencies: asynckit: 0.4.0 combined-stream: 1.0.8 - mime-types: 2.1.26 + mime-types: 2.1.27 dev: false engines: node: '>= 0.12' @@ -439,7 +440,7 @@ packages: integrity: sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= /har-validator/5.1.3: dependencies: - ajv: 6.12.0 + ajv: 6.12.2 har-schema: 2.0.0 dev: false engines: @@ -609,20 +610,20 @@ packages: node: '>= 0.6' resolution: integrity: sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= - /mime-db/1.43.0: + /mime-db/1.44.0: dev: false engines: node: '>= 0.6' resolution: - integrity: sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ== - /mime-types/2.1.26: + integrity: sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== + /mime-types/2.1.27: dependencies: - mime-db: 1.43.0 + mime-db: 1.44.0 dev: false engines: node: '>= 0.6' resolution: - integrity: sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ== + integrity: sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== /mime/1.6.0: dev: false engines: @@ -682,10 +683,10 @@ packages: dev: false resolution: integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - /nan/2.14.0: + /nan/2.14.1: dev: false resolution: - integrity: sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg== + integrity: sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw== /needle/2.4.1: dependencies: debug: 3.2.6 @@ -911,7 +912,7 @@ packages: is-typedarray: 1.0.0 isstream: 0.1.2 json-stringify-safe: 5.0.1 - mime-types: 2.1.26 + mime-types: 2.1.27 oauth-sign: 0.9.0 performance-now: 2.1.0 qs: 6.5.2 @@ -990,7 +991,7 @@ packages: node: '>= 6.0.0' resolution: integrity: sha512-Ibz08vnXvkZ8LJTiUOxRcj1Ckdn7qafNZ2t59jYHMX1VIebTAOYefWdRYFt6z6+hy52WGthAHAoLc9hvk3onqA== - /sequelize/5.21.6: + /sequelize/5.21.7: dependencies: bluebird: 3.7.2 cls-bluebird: 2.1.0 @@ -1011,7 +1012,7 @@ packages: engines: node: '>=6.0.0' resolution: - integrity: sha512-RsgEpP2PP7txeoTWxoLLoe3xX8R2WYQAO7LNba2Ok3/pV5EFfKZry4fJXH56DUHJB909msMCHg0CJKDsQVbjcQ== + integrity: sha512-+JrS5Co7CN53cOFFFaUb+xqQP00wD1Ag9xGLBLoUko2KhRZxjm+UDkqAVPHTUp87McLwJaCPkKv61GPhBVloRQ== /serve-static/1.14.1: dependencies: encodeurl: 1.0.2 @@ -1041,7 +1042,7 @@ packages: integrity: sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== /sqlite3/4.1.1: dependencies: - nan: 2.14.0 + nan: 2.14.1 node-pre-gyp: 0.11.0 request: 2.88.2 dev: false @@ -1161,10 +1162,20 @@ packages: dev: false resolution: integrity: sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= + /twit/2.2.11: + dependencies: + bluebird: 3.7.2 + mime: 1.6.0 + request: 2.88.2 + dev: false + engines: + node: '>=0.10.0' + resolution: + integrity: sha512-BkdwvZGRVoUTcEBp0zuocuqfih4LB+kEFUWkWJOVBg6pAE9Ebv9vmsYTTrfXleZGf45Bj5H3A1/O9YhF2uSYNg== /type-is/1.6.18: dependencies: media-typer: 0.3.0 - mime-types: 2.1.26 + mime-types: 2.1.27 dev: false engines: node: '>= 0.6' @@ -1227,7 +1238,7 @@ packages: integrity: sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== /wkx/0.4.8: dependencies: - '@types/node': 13.11.1 + '@types/node': 13.13.2 dev: false resolution: integrity: sha512-ikPXMM9IR/gy/LwiOSqWlSL3X/J5uk9EO2hHNRXS41eTLXaUFEVw9fn/593jW/tE5tedNg8YjT5HkCa4FqQZyQ== @@ -1247,3 +1258,4 @@ specifiers: express: ^4.17.1 sequelize: '*' sqlite3: '*' + twit: ^2.2.11