bsfe_server/src/routers/group.js

14 lines
986 B
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-10-26 05:31:22 +03:00
export default GroupRouter;