Express/MongoDB backend with JWT auth, RBAC, S3 uploads, notifications, and scheduled jobs.
27 lines
1.5 KiB
JavaScript
27 lines
1.5 KiB
JavaScript
// /components/notifications/notificationRoutes.js
|
|
|
|
const express = require('express');
|
|
const notificationController = require('./notificationController');
|
|
const { validateCreateNotification, validateUpdateNotification } = require('./notificationValidator');
|
|
const authMiddleware = require('../../middlewares/authMiddleware');
|
|
const perm = require('../../middlewares/permissionMiddleware');
|
|
const { PERMISSIONS } = require('../../constants/permissions');
|
|
|
|
const router = express.Router();
|
|
|
|
router.use(authMiddleware);
|
|
|
|
// User Scope
|
|
router.get('/user/my-notifications', notificationController.getMyNotifications);
|
|
|
|
// Admin Scope
|
|
router.post('/admin/create', perm.requires(PERMISSIONS.NOTIFICATIONS_CREATE), validateCreateNotification, notificationController.create);
|
|
router.get('/admin/get-all', perm.requires(PERMISSIONS.NOTIFICATIONS_READ), notificationController.getAll);
|
|
router.get('/admin/search', perm.requires(PERMISSIONS.NOTIFICATIONS_SEARCH), notificationController.search);
|
|
router.get('/admin/get-one/:id', perm.requires(PERMISSIONS.NOTIFICATIONS_READ), notificationController.getOne);
|
|
router.put('/admin/update/:id', perm.requires(PERMISSIONS.NOTIFICATIONS_UPDATE), validateUpdateNotification, notificationController.update);
|
|
router.delete('/admin/delete/:id', perm.requires(PERMISSIONS.NOTIFICATIONS_DELETE), notificationController.delete);
|
|
router.post('/admin/:id/retry', perm.requires(PERMISSIONS.NOTIFICATIONS_RETRY), notificationController.retry);
|
|
|
|
module.exports = router;
|