-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris Whitney
committed
Feb 13, 2020
1 parent
b57f548
commit 7e3fdb0
Showing
7 changed files
with
139 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
DATABASE_URL=localhost | ||
PGUSER=postgres | ||
PGPASSWORD=password | ||
PGDATABASE=home-iot | ||
NODE_ENV=development | ||
DBUSER=user | ||
DBPASS=password | ||
DATABASE=home-iot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require('dotenv').config(); | ||
const mysql = require('mysql2'); | ||
const migration = require('mysql-migrations'); | ||
|
||
const connection = mysql.createPool({ | ||
connectionLimit : 10, | ||
host: 'localhost', | ||
user: process.env.DBUSER, | ||
password: process.env.DBPASS, | ||
database: process.env.DATABASE | ||
}); | ||
|
||
migration.init(connection, __dirname + '/migrations'); | ||
|
||
// https://www.npmjs.com/package/mysql-migrations | ||
// node migrations.js add migration create_table_users | ||
// node migrations.js up | ||
// node migrations.js refresh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
"up": "CREATE TABLE IF NOT EXISTS temps (id SERIAL PRIMARY KEY, ip VARCHAR(16), temp smallint, hum smallint, airQuality smallint, timestamp TIMESTAMP)", | ||
"down": "DROP TABEL temps" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
"up": "CREATE TABLE IF NOT EXISTS rooms (id SERIAL PRIMARY KEY, ip VARCHAR(16), name VARCHAR(16))", | ||
"down": "DROP TABLE rooms" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
const { Pool } = require('pg'); | ||
const mysql = require('mysql2'); | ||
|
||
const connectionString = { | ||
connectionString: process.env.DATABASE_URL, | ||
ssl: true | ||
host: 'localhost', | ||
user: process.env.DBUSER, | ||
password: process.env.DBPASS, | ||
database: process.env.DATABASE | ||
}; | ||
|
||
const pool = new Pool(connectionString); | ||
const pool = mysql.createPool(connectionString); | ||
const promisePool = pool.promise(); | ||
module.exports = { | ||
query: (text, params = []) => pool.query(text, params), | ||
} | ||
query: (text, params = []) => promisePool.query(text, params), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1203,6 +1203,11 @@ ansi-to-html@^0.6.4: | |
dependencies: | ||
entities "^1.1.2" | ||
|
||
ansicolors@~0.3.2: | ||
version "0.3.2" | ||
resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979" | ||
integrity sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk= | ||
|
||
any-promise@^1.3.0: | ||
version "1.3.0" | ||
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" | ||
|
@@ -1747,6 +1752,14 @@ capture-stack-trace@^1.0.0: | |
resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz#a6c0bbe1f38f3aa0b92238ecb6ff42c344d4135d" | ||
integrity sha512-mYQLZnx5Qt1JgB1WEiMCf2647plpGeQ2NMR/5L0HNZzGQo4fuSPnK+wjfPnKZV0aiJDgzmWqqkV/g7JD+DW0qw== | ||
|
||
cardinal@^2.1.1: | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/cardinal/-/cardinal-2.1.1.tgz#7cc1055d822d212954d07b085dea251cc7bc5505" | ||
integrity sha1-fMEFXYItISlU0HsIXeolHMe8VQU= | ||
dependencies: | ||
ansicolors "~0.3.2" | ||
redeyed "~2.1.0" | ||
|
||
caseless@~0.12.0: | ||
version "0.12.0" | ||
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" | ||
|
@@ -2520,6 +2533,11 @@ delegates@^1.0.0: | |
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" | ||
integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= | ||
|
||
denque@^1.4.1: | ||
version "1.4.1" | ||
resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.1.tgz#6744ff7641c148c3f8a69c307e51235c1f4a37cf" | ||
integrity sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ== | ||
|
||
depd@~1.1.2: | ||
version "1.1.2" | ||
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" | ||
|
@@ -2800,7 +2818,7 @@ esprima@^3.1.3: | |
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" | ||
integrity sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM= | ||
|
||
esprima@^4.0.0: | ||
esprima@^4.0.0, esprima@~4.0.0: | ||
version "4.0.1" | ||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" | ||
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== | ||
|
@@ -3158,6 +3176,13 @@ gauge@~2.7.3: | |
strip-ansi "^3.0.1" | ||
wide-align "^1.1.0" | ||
|
||
generate-function@^2.3.1: | ||
version "2.3.1" | ||
resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.3.1.tgz#f069617690c10c868e73b8465746764f97c3479f" | ||
integrity sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ== | ||
dependencies: | ||
is-property "^1.0.2" | ||
|
||
get-caller-file@^2.0.1: | ||
version "2.0.5" | ||
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" | ||
|
@@ -3496,6 +3521,13 @@ [email protected], iconv-lite@^0.4.4: | |
dependencies: | ||
safer-buffer ">= 2.1.2 < 3" | ||
|
||
iconv-lite@^0.5.0: | ||
version "0.5.1" | ||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.5.1.tgz#b2425d3c7b18f7219f2ca663d103bddb91718d64" | ||
integrity sha512-ONHr16SQvKZNSqjQT9gy5z24Jw+uqfO02/ngBSBoqChZ+W8qXX7GPRa1RoUnzGADw8K63R1BXUMzarCVQBpY8Q== | ||
dependencies: | ||
safer-buffer ">= 2.1.2 < 3" | ||
|
||
[email protected], icss-replace-symbols@^1.1.0: | ||
version "1.1.0" | ||
resolved "https://registry.yarnpkg.com/icss-replace-symbols/-/icss-replace-symbols-1.1.0.tgz#06ea6f83679a7749e386cfe1fe812ae5db223ded" | ||
|
@@ -3817,6 +3849,11 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4: | |
dependencies: | ||
isobject "^3.0.1" | ||
|
||
is-property@^1.0.2: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" | ||
integrity sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ= | ||
|
||
is-redirect@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" | ||
|
@@ -4633,6 +4670,11 @@ log-symbols@^2.2.0: | |
dependencies: | ||
chalk "^2.0.1" | ||
|
||
long@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" | ||
integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== | ||
|
||
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: | ||
version "1.4.0" | ||
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" | ||
|
@@ -4645,14 +4687,21 @@ lowercase-keys@^1.0.0: | |
resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" | ||
integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== | ||
|
||
lru-cache@^4.0.1: | ||
lru-cache@^4.0.1, lru-cache@^4.1.3: | ||
version "4.1.5" | ||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" | ||
integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== | ||
dependencies: | ||
pseudomap "^1.0.2" | ||
yallist "^2.1.2" | ||
|
||
lru-cache@^5.1.1: | ||
version "5.1.1" | ||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" | ||
integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== | ||
dependencies: | ||
yallist "^3.0.2" | ||
|
||
magic-string@^0.22.4: | ||
version "0.22.5" | ||
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.22.5.tgz#8e9cf5afddf44385c1da5bc2a6a0dbd10b03657e" | ||
|
@@ -4883,6 +4932,33 @@ ms@^2.1.1: | |
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" | ||
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== | ||
|
||
mysql-migrations@^1.0.6: | ||
version "1.0.6" | ||
resolved "https://registry.yarnpkg.com/mysql-migrations/-/mysql-migrations-1.0.6.tgz#ec9e021127ac38460bee05178fc93d48cea0d0a4" | ||
integrity sha1-7J4CESesOEYL7gUXj8k9SM6g0KQ= | ||
|
||
mysql2@^2.1.0: | ||
version "2.1.0" | ||
resolved "https://registry.yarnpkg.com/mysql2/-/mysql2-2.1.0.tgz#55ecfd4353114c148cc4c253192dbbfd000e6642" | ||
integrity sha512-9kGVyi930rG2KaHrz3sHwtc6K+GY9d8wWk1XRSYxQiunvGcn4DwuZxOwmK11ftuhhwrYDwGx9Ta4VBwznJn36A== | ||
dependencies: | ||
cardinal "^2.1.1" | ||
denque "^1.4.1" | ||
generate-function "^2.3.1" | ||
iconv-lite "^0.5.0" | ||
long "^4.0.0" | ||
lru-cache "^5.1.1" | ||
named-placeholders "^1.1.2" | ||
seq-queue "^0.0.5" | ||
sqlstring "^2.3.1" | ||
|
||
named-placeholders@^1.1.2: | ||
version "1.1.2" | ||
resolved "https://registry.yarnpkg.com/named-placeholders/-/named-placeholders-1.1.2.tgz#ceb1fbff50b6b33492b5cf214ccf5e39cef3d0e8" | ||
integrity sha512-wiFWqxoLL3PGVReSZpjLVxyJ1bRqe+KKJVbr4hGs1KWfTZTQyezHFBbuKj9hsizHyGV2ne7EMjHdxEGAybD5SA== | ||
dependencies: | ||
lru-cache "^4.1.3" | ||
|
||
nan@^2.12.1: | ||
version "2.14.0" | ||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c" | ||
|
@@ -6357,6 +6433,13 @@ recharts@^1.7.1: | |
recharts-scale "^0.4.2" | ||
reduce-css-calc "^1.3.0" | ||
|
||
redeyed@~2.1.0: | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/redeyed/-/redeyed-2.1.1.tgz#8984b5815d99cb220469c99eeeffe38913e6cc0b" | ||
integrity sha1-iYS1gV2ZyyIEacme7v/jiRPmzAs= | ||
dependencies: | ||
esprima "~4.0.0" | ||
|
||
reduce-css-calc@^1.3.0: | ||
version "1.3.0" | ||
resolved "https://registry.yarnpkg.com/reduce-css-calc/-/reduce-css-calc-1.3.0.tgz#747c914e049614a4c9cfbba629871ad1d2927716" | ||
|
@@ -6719,6 +6802,11 @@ [email protected]: | |
range-parser "~1.2.1" | ||
statuses "~1.5.0" | ||
|
||
seq-queue@^0.0.5: | ||
version "0.0.5" | ||
resolved "https://registry.yarnpkg.com/seq-queue/-/seq-queue-0.0.5.tgz#d56812e1c017a6e4e7c3e3a37a1da6d78dd3c93e" | ||
integrity sha1-1WgS4cAXpuTnw+Ojeh2m143TyT4= | ||
|
||
sequelize-pool@^2.3.0: | ||
version "2.3.0" | ||
resolved "https://registry.yarnpkg.com/sequelize-pool/-/sequelize-pool-2.3.0.tgz#64f1fe8744228172c474f530604b6133be64993d" | ||
|
@@ -6951,6 +7039,11 @@ sprintf-js@~1.0.2: | |
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" | ||
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= | ||
|
||
sqlstring@^2.3.1: | ||
version "2.3.1" | ||
resolved "https://registry.yarnpkg.com/sqlstring/-/sqlstring-2.3.1.tgz#475393ff9e91479aea62dcaf0ca3d14983a7fb40" | ||
integrity sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A= | ||
|
||
sshpk@^1.7.0: | ||
version "1.16.1" | ||
resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877" | ||
|
@@ -7863,7 +7956,7 @@ yallist@^2.1.2: | |
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" | ||
integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= | ||
|
||
yallist@^3.0.0, yallist@^3.0.3: | ||
yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3: | ||
version "3.1.1" | ||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" | ||
integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== | ||
|