bsfe_server/src/routers/group.js

17 lines
1.5 KiB
JavaScript
Raw Normal View History

2024-10-26 05:31:22 +03:00
import { Router } from 'express';
import auth from '../middlewares/auth.js';
2024-10-27 05:45:12 +03:00
import GroupController from '../controllers/group.js';
import tryHandler from '../response/errorHandler.js';
2024-10-31 07:47:27 +03:00
import existance from '../middlewares/existance.js';
2024-10-26 05:31:22 +03:00
const GroupRouter = new Router();
GroupRouter.post('/create/:groupName', tryHandler(auth.authenticate), tryHandler(GroupController.create));
2024-10-31 07:47:27 +03:00
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));
2024-10-31 10:06:49 +03:00
GroupRouter.get('/byName/:groupName', tryHandler(auth.authenticate), tryHandler(existance.groupNameExists), tryHandler(GroupController.getByName))
2024-11-02 22:15:24 +03:00
GroupRouter.get('/byId/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.userIsInGroup), tryHandler(GroupController.getById))
2024-11-02 21:51:29 +03:00
GroupRouter.get('/getUsers/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.userIsInGroup), tryHandler(GroupController.getUsersInGroup))
2024-11-03 00:01:54 +03:00
GroupRouter.get('/adminId/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.userIsInGroup), tryHandler(GroupController.getAdminId))
2024-10-26 05:31:22 +03:00
export default GroupRouter;