generated from lucien/api-template
add: added homepage
This commit is contained in:
parent
1f24907c80
commit
4ea8c9f2b3
11 changed files with 239 additions and 68 deletions
|
@ -10,19 +10,10 @@ router.get('/:id', async (req, res) => {
|
|||
const users = await getUser(connection, id);
|
||||
connection.end();
|
||||
if (users[0]) {
|
||||
res.send(users[0]);
|
||||
res.send({id: users[0].id, username: users[0].username});
|
||||
} else {
|
||||
res.send('No user found');
|
||||
}
|
||||
});
|
||||
|
||||
router.post('/add', async (req, res) => {
|
||||
const { username, password } = req.body;
|
||||
const connection = await getConnection();
|
||||
const hash = sha256(password);
|
||||
await addUser(connection, username, hash);
|
||||
connection.end();
|
||||
res.send({ message: 'User added' });
|
||||
});
|
||||
|
||||
module.exports = router;
|
Loading…
Add table
Add a link
Reference in a new issue