@replyke/express
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
26 lines (25 loc) • 779 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const models_1 = require("../../../models");
exports.default = async (req, res) => {
try {
const loggedInUserId = req.userId;
const projectId = req.project.id;
const count = await models_1.AppNotification.count({
where: {
projectId,
userId: loggedInUserId,
isRead: false,
},
});
res.status(200).json(count);
}
catch (err) {
console.error("Error counting unread app notifications:", err);
res.status(500).json({
error: "Internal server error.",
code: "app-notification/server-error",
details: err.message,
});
}
};