import express from 'express'; import validate from 'express-validation'; import { authorize } from '../../middlewares/auth.middleware'; import middleware from '../../middlewares/user.middleware'; import controller from '../../controllers/v1/user.controller'; import permissions from '../../../common/utils/Permissions'; import { listValidation, updateValidation, createValidation, } from '../../validations/v1/user.validation'; const router = express.Router(); router .route('/') .get( validate(listValidation), middleware.count, controller.list ) .post( validate(createValidation), // authorize([permissions.USER_CREATE]), middleware.checkEmail, controller.create ); router .route('/:id') .get( middleware.load, controller.get ) .put( validate(updateValidation), authorize([permissions.USER_UPDATE]), middleware.load, controller.update ) .delete( authorize([permissions.USER_DELETE]), middleware.load, controller.delete ); export default router;