Skip to content

Commit

Permalink
Refactor users.js for minor updates and delete users.sql
Browse files Browse the repository at this point in the history
Co-authored-by: cherhchen <[email protected]>
  • Loading branch information
h0ethan04 and cherhchen committed Dec 13, 2023
1 parent 49e1bca commit cabe258
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
8 changes: 4 additions & 4 deletions routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ userRouter.post('/', async (req, res) => {
approved,
]);
res.status(201).json({
status: 'Success',
id,
});
} catch (err) {
res.status(500).json({
Expand All @@ -49,7 +49,7 @@ userRouter.put('/:uid', async (req, res) => {
`UPDATE users SET approved = TRUE WHERE id = $1 RETURNING *;`,
[uid],
);
return res.status(200).send(updatedApproval[0]);
return res.status(200).send(keysToCamel(updatedApproval));
} catch (err) {
return res.status(500).send(err.message);
}
Expand All @@ -58,8 +58,8 @@ userRouter.put('/:uid', async (req, res) => {
userRouter.delete('/:uid', async (req, res) => {
try {
const { uid } = req.params;
await db.query(`DELETE FROM users WHERE id = $1;`, [uid]);
res.status(200).send('Deleted user');
const deletedUser = await db.query(`DELETE FROM users WHERE id = $1 RETURNING *;`, [uid]);
res.status(200).send(keysToCamel(deletedUser));
} catch (err) {
res.status(500).send(err.message);
}
Expand Down
29 changes: 0 additions & 29 deletions server/queries/users.sql

This file was deleted.

0 comments on commit cabe258

Please sign in to comment.