Skip to content

Commit 57b3d84

Browse files
committed
feat: Improved tests and make api restful
Now tests execute a fetch to all the apis
1 parent bddce59 commit 57b3d84

File tree

11 files changed

+1524
-169
lines changed

11 files changed

+1524
-169
lines changed

webserver/api/integrations/db.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,24 @@ async function getUserProfilePic(username) {
158158
* from the table
159159
*/
160160
async function getTableData(tab) {
161-
// console.log('[getTreeView] input', siteId);
162161
let checkRes = false
163162
const res = []
163+
let tabName = "";
164+
165+
switch (tab) { // To prevent for sql injection
166+
case 'dataset':
167+
tabName = 'dataset'
168+
break
169+
default:
170+
tabName = "dataset"
171+
break
172+
}
173+
164174
const dataQuery = {
165-
text: `select * from $1;`,
166-
values: [tab]
175+
text: `SELECT * FROM ${tabName};`,
176+
values: []
167177
}
178+
168179
try {
169180
const res = await pool.query(dataQuery)
170181
checkRes = res.rowCount > 0
@@ -222,7 +233,7 @@ async function createUser(inputs) {
222233
*/
223234
async function deleteUser(username) {
224235
const query = {
225-
text: 'UPDATE users SET user_disabled = TRUE ' +
236+
text: 'DELETE FROM users ' +
226237
'WHERE username = $1',
227238
values: [username]
228239
}

0 commit comments

Comments
 (0)