text: const httpStatus = require('http-status');
  const pick = require('../utils/pick');
  const ApiError = require('../utils/ApiError');
  const catchAsync = require('../utils/catchAsync');
  const { notificationService } = require('../services');
  
  const createNotification = catchAsync(async (req, res) => {
    const notification = await notificationService.createNotification(req.body);
    res.status(httpStatus.CREATED).send(notification);
  });
  
  const getNotifications = catchAsync(async (req, res) => {
    const filter = pick(req.query, ['name', 'role']);
    const options = pick(req.query, ['sortBy', 'limit', 'page']);
    const result = await notificationService.queryNotifications(filter, options);
    res.send(result);
  });
  
  const getNotification = catchAsync(async (req, res) => {
    const notification = await notificationService.getNotificationById(req.params.notificationId);
    if (!notification) {
      throw new ApiError(httpStatus.NOT_FOUND, 'Notification not found');
    }
    res.send(notification);
  });
  
  const getUnseenNotifications = catchAsync(async (req, res) => {
    const filter = { userId: req.user._id, seen: false };
    const options = pick(req.query, ['sortBy', 'limit', 'page']);
    const result = await notificationService.queryNotifications(filter, options);
    console.log(result.docs.length);
    res.json({ count: result.docs.length });
  });
  
  const updateNotification = catchAsync(async (req, res) => {
    const notification = await notificationService.updateNotificationById(req.params.notificationId, req.body);
    res.send(notification);
  });
  
  const deleteNotification = catchAsync(async (req, res) => {
    await notificationService.deleteNotificationById(req.params.notificationId);
    res.status(httpStatus.NO_CONTENT).send();
  });
  
  module.exports = {
    createNotification,
    getNotifications,
    getNotification,
    updateNotification,
    deleteNotification,
    getUnseenNotifications,
  };
  