add: added homepage

This commit is contained in:
Lukian 2025-03-24 14:41:48 +01:00
parent 1f24907c80
commit 4ea8c9f2b3
11 changed files with 239 additions and 68 deletions

View file

@ -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;