From 9cd1debd4ae546b0197709076b67554b0aa07a64 Mon Sep 17 00:00:00 2001 From: leca Date: Thu, 31 Oct 2024 09:00:44 +0300 Subject: [PATCH] added new endpoint --- src/controllers/group.js | 8 ++++++++ src/routers/group.js | 1 + 2 files changed, 9 insertions(+) diff --git a/src/controllers/group.js b/src/controllers/group.js index 4ec6568..c939e02 100644 --- a/src/controllers/group.js +++ b/src/controllers/group.js @@ -39,6 +39,14 @@ class GroupController { 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(); \ No newline at end of file diff --git a/src/routers/group.js b/src/routers/group.js index e3c4cd0..f486630 100644 --- a/src/routers/group.js +++ b/src/routers/group.js @@ -9,5 +9,6 @@ const GroupRouter = new Router(); 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('/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; \ No newline at end of file