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,45 @@
|
||||
// /components/notifications/notificationController.js
|
||||
|
||||
const catchAsync = require('../../utils/catchAsync');
|
||||
const notificationService = require('./notificationService');
|
||||
const { successResponse, listResponse } = require('../../utils/apiResponse');
|
||||
|
||||
exports.create = catchAsync(async (req, res, next) => {
|
||||
const notification = await notificationService.createNotification(req.body);
|
||||
return successResponse(res, 201, 'Notification created successfully', notification);
|
||||
});
|
||||
|
||||
exports.getOne = catchAsync(async (req, res, next) => {
|
||||
const notification = await notificationService.getNotificationById(req.params.id);
|
||||
return successResponse(res, 200, 'Notification retrieved successfully', notification);
|
||||
});
|
||||
|
||||
exports.getAll = catchAsync(async (req, res, next) => {
|
||||
const { data, meta } = await notificationService.getAllNotifications(req.query);
|
||||
return listResponse(res, 200, data, meta);
|
||||
});
|
||||
|
||||
exports.update = catchAsync(async (req, res, next) => {
|
||||
const notification = await notificationService.updateNotification(req.params.id, req.body);
|
||||
return successResponse(res, 200, 'Notification updated successfully', notification);
|
||||
});
|
||||
|
||||
exports.delete = catchAsync(async (req, res, next) => {
|
||||
await notificationService.deleteNotification(req.params.id);
|
||||
return successResponse(res, 200, 'Notification deleted successfully');
|
||||
});
|
||||
|
||||
exports.search = catchAsync(async (req, res, next) => {
|
||||
const { data, meta } = await notificationService.searchNotifications(req.query);
|
||||
return listResponse(res, 200, data, meta);
|
||||
});
|
||||
|
||||
exports.retry = catchAsync(async (req, res, next) => {
|
||||
const result = await notificationService.retryNotification(req.params.id);
|
||||
return successResponse(res, 200, 'Notification retried successfully', result);
|
||||
});
|
||||
|
||||
exports.getMyNotifications = catchAsync(async (req, res, next) => {
|
||||
const { data, meta } = await notificationService.getMyNotifications(req.user._id, req.query);
|
||||
return listResponse(res, 200, data, meta);
|
||||
});
|
||||
Reference in New Issue
Block a user