-
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.
starting off with a database bonanza (#126)
* starting off with a database bonanza * readme updates * Delete .eslintrc.js a test, yes * Create .eslintrc.js * Update .eslintrc.js * Delete .eslintrc.js * updates * updates for #127 and #130 * more of #130 changes * updates for #128 * removing graphs temporarily for #30 * more for #128, #129 new tests required * shrinkwraps v4.6.0
- Loading branch information
Showing
30 changed files
with
2,288 additions
and
886 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
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
require("dotenv").config() | ||
const Pool = require('pg').Pool | ||
const pool = new Pool({ | ||
user: process.env.database_USER, | ||
host: process.env.database_HOST, | ||
database: process.env.database_NAME, | ||
password: process.env.database_PASSWORD, | ||
port: process.env.database_PORT, | ||
}) | ||
|
||
const creationTasks = [ | ||
{ | ||
query: `CREATE TABLE frame_files(ID SERIAL PRIMARY KEY, timestamp TIMESTAMP, camera NUMERIC(10), name VARCHAR, size NUMERIC);`, | ||
description: "frame files table" | ||
}, | ||
{ | ||
query: `CREATE TABLE frame_deletes(ID SERIAL PRIMARY KEY, timestamp TIMESTAMP, camera NUMERIC(10), size NUMERIC, count NUMERIC);`, | ||
description: "frame deletions table" | ||
}, | ||
{ | ||
query: `CREATE TABLE auth(ID SERIAL PRIMARY KEY, username VARCHAR(10) UNIQUE, hash VARCHAR);`, | ||
description: "authorization table" | ||
} | ||
] | ||
|
||
Promise.allSettled(creationTasks.map(({query}) => { | ||
return pool.query(query) | ||
})).then(values => { | ||
let issues = false | ||
values.forEach((value, index) => { | ||
const tableExists = value.status == "fulfilled" || (value.status == "rejected" && value.reason && value.reason.code == `42P07`) | ||
if(!tableExists) issues = true | ||
console.log(`${creationTasks[index].description} ${tableExists ? `✔️` : `❌`}`) | ||
}) | ||
process.exit(issues ? 1 : 0) | ||
}) |
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
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,20 @@ | ||
const bcrypt = jest.requireActual("bcryptjs") | ||
const hashedMockedPassword = bcrypt.hashSync('mockedPassword', bcrypt.genSaltSync(10)) | ||
|
||
const queryObject = { | ||
query: (str, callback) => callback(null, {rows: [{hash: hashedMockedPassword}]}) | ||
} | ||
const mockedPool = { | ||
connect: () => { | ||
return queryObject | ||
}, | ||
...queryObject, | ||
end: jest.fn(), | ||
on: jest.fn() | ||
} | ||
|
||
const pg = { | ||
Pool: jest.fn(() => mockedPool) | ||
} | ||
|
||
module.exports = pg |
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
Oops, something went wrong.