Skip to content

Commit

Permalink
Co-authored-by: cherhchen <[email protected]>
Browse files Browse the repository at this point in the history
  • Loading branch information
h0ethan04 committed Nov 28, 2023
1 parent 2743622 commit 188e789
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions routes/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const express = require('express');
const { keysToCamel } = require('../common/utils');
const { db } = require('../server/db');

const userRouter = express.Router();

userRouter.get('/', async (req, res) => {
try {
const allUsers = await db.query(`SELECT * FROM users;`);
res.status(200).json(keysToCamel(allUsers));
} catch (err) {
console.log(err);
res.status(500).send(err.message);
}
});


userRouter.get('/pending-accounts', async (req, res) => {
try {
const pendingAccounts = await db.query(`SELECT * FROM users WHERE approved = FALSE;`);
res.status(200).json(keysToCamel(pendingAccounts));
} catch (err) {
console.log(err);
res.status(500).send(err.message);
}
});


userRouter.post('/', async (req, res) => {
try {
const { id, email, type, approved } = req.params;
} catch (err) {

}
});

userRouter.put('/:uid', async (req, res) => {
try {

} catch (err) {

}
});

userRouter.delete('/:uid', async (req, res) => {
try {

} catch (err) {

}
});

0 comments on commit 188e789

Please sign in to comment.