UNPKG

@replyke/express

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

25 lines (24 loc) 841 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const models_1 = require("../../../../models"); // Fetch a follow relationship exports.default = async (req, res) => { const { userId: followedId } = req.params; const loggedInUserId = req.userId; const projectId = req.project.id; try { // Check if the follow relationship exists const followExists = await models_1.Follow.findOne({ where: { projectId, followerId: loggedInUserId, followedId }, }); res.status(200).json({ isFollowing: !!followExists }); } catch (err) { console.error("Error fetching follow:", err); res.status(500).json({ error: "Internal server error.", code: "follow/server-error", details: err.message, }); } };