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';
|
2024-10-31 06:33:57 +03:00
|
|
|
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();
|
|
|
|
|
2024-10-31 06:33:57 +03:00
|
|
|
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 21:51:29 +03:00
|
|
|
GroupRouter.get('/getUsers/:groupId', tryHandler(auth.authenticate), tryHandler(existance.groupExists), tryHandler(auth.userIsInGroup), tryHandler(GroupController.getUsersInGroup))
|
2024-10-26 05:31:22 +03:00
|
|
|
export default GroupRouter;
|