added new endpoint

This commit is contained in:
leca 2024-10-31 09:00:44 +03:00
parent d4233c72f5
commit 9cd1debd4a
2 changed files with 9 additions and 0 deletions

View File

@ -39,6 +39,14 @@ class GroupController {
return res.status(200).send(translate(req.headers["accept-language"], responseCodes.responses.general.ok)); return res.status(200).send(translate(req.headers["accept-language"], responseCodes.responses.general.ok));
} }
async getByName(req, res) {
let groupName = req.params.groupName || req.body.groupName;
let id = await GroupService.getByName(groupName);
return res.status(200).send(id);
}
} }
export default new GroupController(); export default new GroupController();

View File

@ -9,5 +9,6 @@ const GroupRouter = new Router();
GroupRouter.post('/create/:groupName', tryHandler(auth.authenticate), tryHandler(GroupController.create)); GroupRouter.post('/create/:groupName', tryHandler(auth.authenticate), tryHandler(GroupController.create));
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.groupExists), tryHandler(GroupController.getByName))
export default GroupRouter; export default GroupRouter;