Initial commit: teaching institution management API.
Express/MongoDB backend with JWT auth, RBAC, S3 uploads, notifications, and scheduled jobs.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// /components/roles/roleController.js
|
||||
|
||||
const catchAsync = require('../../utils/catchAsync');
|
||||
const roleService = require('./roleService');
|
||||
const { successResponse, listResponse } = require('../../utils/apiResponse');
|
||||
|
||||
exports.createRole = catchAsync(async (req, res, next) => {
|
||||
const role = await roleService.createRole(req.body);
|
||||
return successResponse(res, 201, 'Role created successfully', role);
|
||||
});
|
||||
|
||||
exports.getRole = catchAsync(async (req, res, next) => {
|
||||
const role = await roleService.getRole(req.params.id);
|
||||
return successResponse(res, 200, 'Role retrieved successfully', role);
|
||||
});
|
||||
|
||||
exports.getAllRoles = catchAsync(async (req, res, next) => {
|
||||
const { data, meta } = await roleService.getAllRoles(req.query);
|
||||
return listResponse(res, 200, data, meta);
|
||||
});
|
||||
|
||||
exports.updateRole = catchAsync(async (req, res, next) => {
|
||||
const role = await roleService.updateRole(req.params.id, req.body);
|
||||
return successResponse(res, 200, 'Role updated successfully', role);
|
||||
});
|
||||
|
||||
exports.deleteRole = catchAsync(async (req, res, next) => {
|
||||
await roleService.deleteRole(req.params.id);
|
||||
return successResponse(res, 200, 'Role deleted successfully');
|
||||
});
|
||||
|
||||
exports.searchRoles = catchAsync(async (req, res, next) => {
|
||||
const { data, meta } = await roleService.searchRoles(req.query);
|
||||
return listResponse(res, 200, data, meta);
|
||||
});
|
||||
Reference in New Issue
Block a user