generated from lucien/api-template
fix: fixed user creation and channel creation
This commit is contained in:
parent
42eb432b58
commit
5d13a51f8e
3 changed files with 19 additions and 1 deletions
|
@ -70,6 +70,17 @@ router.post('/add', async (req, res) => {
|
|||
return res.status(401).send({ error: 'Invalid token' });
|
||||
}
|
||||
|
||||
const channel = await getChannel(connection, name);
|
||||
if (channel[0]) {
|
||||
connection.end();
|
||||
return res.status(400).send({ error: 'Channel already exists' });
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z0-9-_]+$/.test(name)) {
|
||||
connection.end();
|
||||
return res.status(400).send({ error: 'Invalid channel name' });
|
||||
}
|
||||
|
||||
await addChannel(connection, name, description);
|
||||
connection.end();
|
||||
res.send({ message: 'Channel added' });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue