added new endpoint

This commit is contained in:
leca 2024-11-02 22:15:24 +03:00
parent 317fba81aa
commit c34cd7f809
2 changed files with 9 additions and 0 deletions

View File

@ -49,6 +49,14 @@ class GroupController {
return res.status(200).send(group["id"].toString()); return res.status(200).send(group["id"].toString());
} }
async getById(req, res) {
let groupId = req.params.groupId;
let groupName = (await GroupService.getById(groupId)).name;
return res.status(200).send(groupName);
}
async getUsersInGroup(req, res) { async getUsersInGroup(req, res) {
const groupId = req.params.groupId; const groupId = req.params.groupId;

View File

@ -10,5 +10,6 @@ GroupRouter.post('/create/:groupName', tryHandler(auth.authenticate), tryHandler
GroupRouter.post('/join/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.requirePassword), tryHandler(auth.checkGroupPassword), tryHandler(GroupController.join)); GroupRouter.post('/join/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.requirePassword), tryHandler(auth.checkGroupPassword), tryHandler(GroupController.join));
GroupRouter.post('/password/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.authorizeGroupOwner), tryHandler(auth.requirePassword), tryHandler(GroupController.updatePassword)); GroupRouter.post('/password/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.authorizeGroupOwner), tryHandler(auth.requirePassword), tryHandler(GroupController.updatePassword));
GroupRouter.get('/byName/:groupName', tryHandler(auth.authenticate), tryHandler(existance.groupNameExists), tryHandler(GroupController.getByName)) GroupRouter.get('/byName/:groupName', tryHandler(auth.authenticate), tryHandler(existance.groupNameExists), tryHandler(GroupController.getByName))
GroupRouter.get('/byId/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.userIsInGroup), tryHandler(GroupController.getById))
GroupRouter.get('/getUsers/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.userIsInGroup), tryHandler(GroupController.getUsersInGroup)) GroupRouter.get('/getUsers/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.userIsInGroup), tryHandler(GroupController.getUsersInGroup))
export default GroupRouter; export default GroupRouter;