Skip to content

Commit

Permalink
feat: Improved tests and make api restful
Browse files Browse the repository at this point in the history
Now tests execute a fetch to all the apis
  • Loading branch information
Elius94 committed Nov 30, 2021
1 parent bddce59 commit 57b3d84
Show file tree
Hide file tree
Showing 11 changed files with 1,524 additions and 169 deletions.
19 changes: 15 additions & 4 deletions webserver/api/integrations/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,24 @@ async function getUserProfilePic(username) {
* from the table
*/
async function getTableData(tab) {
// console.log('[getTreeView] input', siteId);
let checkRes = false
const res = []
let tabName = "";

switch (tab) { // To prevent for sql injection
case 'dataset':
tabName = 'dataset'
break
default:
tabName = "dataset"
break
}

const dataQuery = {
text: `select * from $1;`,
values: [tab]
text: `SELECT * FROM ${tabName};`,
values: []
}

try {
const res = await pool.query(dataQuery)
checkRes = res.rowCount > 0
Expand Down Expand Up @@ -222,7 +233,7 @@ async function createUser(inputs) {
*/
async function deleteUser(username) {
const query = {
text: 'UPDATE users SET user_disabled = TRUE ' +
text: 'DELETE FROM users ' +
'WHERE username = $1',
values: [username]
}
Expand Down
Loading

0 comments on commit 57b3d84

Please sign in to comment.