You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
upload-file-backend/src/api/routes/v1/staff.route.js

88 lines
2.0 KiB

import express from 'express';
import validate from 'express-validation';
import middleware from '../../middlewares/staff.middleware';
import controller from '../../controllers/v1/staff.controller';
import permissions from '../../../common/utils/Permissions';
import { authorize } from '../../middlewares/auth.middleware';
import {
// listValidation,
updateValidation,
createValidation
} from '../../validations/v1/staff.validation';
const router = express.Router();
router
.route('/')
.get(
authorize([permissions.SERVICE]),
middleware.count,
// middleware.load,
controller.list
)
.post(
validate(createValidation),
authorize([permissions.SERVICE]),
middleware.prepareParams,
middleware.checkExistingEmail,
controller.create
);
router
.route('/:id')
.get(
authorize([permissions.SERVICE]),
middleware.load,
controller.get
// controller.addService
)
.put(
validate(updateValidation),
authorize([permissions.SERVICE]),
middleware.load,
middleware.prepareParamsUpdated,
controller.update
)
.delete(
authorize([permissions.SERVICE]),
middleware.load,
controller.delete
);
router
.route('/:id/block')
.post(
authorize([permissions.STAFF]),
middleware.load,
controller.block
);
router
.route('/:id/active')
.post(
authorize([permissions.STAFF]),
middleware.load,
controller.active
);
// super admin change password for themself
router
.route("/resetpassword/:id")
.post(
authorize([permissions.SERVICE]),
middleware.load,
middleware.checkCurrentPassword,
controller.changePassword
);
//super admin change password for admin
router
.route("/change-password/:id")
.post(
authorize([permissions.SERVICE]),
middleware.load,
controller.changePassword
);
export default router;